[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-419?page=co...
]
Francisco Peredo commented on EJB-419:
--------------------------------------
All right, al right, it does not actually say that, but I accept Gavin's
interpretation (it is after all EclipseLink interpretation too), but that still means
Hibernate has a bug (more info on referenced forum topic and EJB-441).
EntityManager.persist validation: Inconsistent with other JPA
Implemetations
------------------------------------------------------------------------------
Key: EJB-419
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-419
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.3.2.GA
Reporter: Francisco Peredo
With the following JPA @Entity:
@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;
}
@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();
}
Where does/should it crash?:
1. At the line em.persist(customer); because the name is configured as nullable=false,
and we are trying to persist the Customer instance with a null value in the name property
2. em.getTransaction().commit(); because the name is configured as nullable=false, and we
are trying to commit the transaction with a null value in the name property
Turns out... that the answer depends on the JPA provider you are using! If using
Hibernate, it crashes at em.persist, but if using EclipseLink, it crashes at
em.getTransaction().commit.
I think Hibernate it should validate this kind of things at em.getTransaction().commit()
and not at em.persist.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira