]
Francisco Peredo commented on HHH-4151:
---------------------------------------
Thanks a lot!
nullable=true is ONLY a hint for schema generation, but Hibernate
uses it for validation
----------------------------------------------------------------------------------------
Key: HHH-4151
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4151
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Reporter: Francisco Peredo
With the following JPA @Entity (note the @Basic(optional=true), @Column(nullable=false)
at the getName method):
@Entity
public class Customer {
private Long id;
private String name;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Basic(optional=true)
@Column(nullable=false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
And then the following test
@Test
public void persistCustomerInTransaction() throws Exception {
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
Customer customer = new Customer();
em.persist(customer);em.getTransaction().commit();
em.close();
}
What exception should be the root cause of this problem?
According to the spec @Column(nullable=false) is JUST a schema generation hint, and
Hibernate should NOT use it for object level validation, so it should crash with a
java.sql.SQLException as the root exception, and not with a
org.hibernate.PropertyValueException thrown by
org.hibernate.engine.Nullability.checkNullability.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: