[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-419) EntityManager.persist validation: Inconsistent with other JPA Implemetations
Francisco Peredo (JIRA)
noreply at atlassian.com
Tue Jun 2 10:13:13 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33306#action_33306 ]
Francisco Peredo commented on EJB-419:
--------------------------------------
Who said anything about schema generation being wrong? I did not...
What I said was that I wanted transactional validation!
This has nothing to do with schema generation, and if nullable=true is only about schema generation, then why there is code inside entityManager.persist it that validates using nullable=true as a trigger? the error (if any error should happen) should come from the database and only AFTER the insert is executed. So hibernate behavior is still wrong.
Can you point me to the place in the space where it says that nullable=true should be validated the moment em.persist is called, and not when the transaction is committed? because I could not find it. Did you even read all my posts in forum thread (specially the third one)?
And please, before rejecting bug reports, try reading the forum posts . Thanks
> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list