A
A
Alexey Kopendakov2018-02-19 22:52:05
Java
Alexey Kopendakov, 2018-02-19 22:52:05

How to correctly describe an entity in hibernate?

There is already a populated table in mysql, one of whose fields is defined like this:
`mark` smallint(6) DEFAULT NULL,
In entity I have defined this field like this:

@Column(name = "mark",nullable = true)
    private short mark;

But the whole problem is that if this field is a number in the record, then everything is fine, and if NULL, then even without getting into the setter, an exception is thrown. "javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of pst.asu.beans.order.domain.OrderEntity.mark" The
base cannot be touched :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2018-02-19
@alex_kag

Null value was assigned to a property of primitive >type

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question