Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Validation constraint and preInsertListener
PostPosted: Mon Mar 06, 2017 11:26 am 
Newbie

Joined: Mon Mar 06, 2017 11:06 am
Posts: 1
I am wokring in a project that use hibernate 4.1.7.FINAL and I am using an implementation of preInsertEventListener to override the preInsert Method and javax.persistence.Column for validation (nullable=false ) every things gone right in 4.1.7.FINAL.

But when i upgrade the hibernate version to 5.2.8.FINAL the project throw an exception of null proprety because i am setting the proprety in the preInsert Method so as i see the hibernate lifecycle change to check the constraint validation before preInsert Method. I guess .

And when I added the hibernate validator dependecy every thing gone ok, and no thrown exception, without writting any line of code,I really want to know what happend exactly and if the constraint validation before the preInsert method why documentation doesn't say that (The domcumentation say the opposite of that : Whenever a PreInsertEvent, PreUpdateEvent or PreDeleteEvent occurs, the listener will verify all constraints of the entity instance and throw an exception).

Why the validation check lifecycle change from hibernate 4 to hibernate 5 it was before preInsert and now after preInsert ?

To Resume without the validator dependecy the constraint check validation is before the preInsert method and after adding the validator dependecy the constraint check validation is after the preInsert method get excuted how that works ?

THANKS.


Last edited by DMK-DEV on Mon Mar 06, 2017 2:08 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Validation constraint and preInsertListener
PostPosted: Mon Mar 06, 2017 1:26 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1103
Can you rephrase your question because it's hard to follow what you are asking. Try to split it on multiple paragraphs, add some code examples, and refernce to the docs which you think they are stale.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.