Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deleting causes : not-null property references a null or transient value

 
taylor kiani
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
i'm getting this error when i try to delete a record in my datatable ;

#{PersonneRecontreeBean.delete}: org.hibernate.PropertyValueException: not-null property references a null or transient value: Dac.Entity.Audit.statu

i'm gussing it has to do with the way i structure my entetys so let me explain how it goes:

i have an entety "audit"


the entety i'm trying to delete:


and the entety where it is pointing in the error


and if it should help the entire error:


i'm nnot sure where the probleme is!
thank you for your time!
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where you have this:
taylor kiani wrote:

You're saying that statu can't be null. But that error suggests it is null. Where do you initialise it to something else? (And if the answer is "nowhere", I think that's your problem!)
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are still misusing CascadeType.REMOVE

go re-read my comments in this thread
http://www.coderanch.com/t/590146/ORM/databases/hibernat-creating-tables-without-cascade

Once again there is there is no setting in JPA that can be applied to a relationship from one entity to another that will cause it to be removed from a parent. Relationship maintenance is the responsibility of the application.

 
taylor kiani
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i solved many problemes after that but it seems that i havn't figured it out completely :p.
any way this time i am not trying to delete it from a parent entety and it is not the parent to any entity.

for the statu it's not null i sysouted it before deleting!
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said I think there are very very very few (if any) scenarios where it ever makes sense to have a CascadeType.REMOVE on anything other than a @OneToOne or @OneToMany. You have them all over the place including on @ManyToOne and @ManyToMany. I reiterated this twice in the other thread. I do not doubt that you have slapped this on there thinking it is somehow going to manage your relationships for you. It does not work like that the application needs to manage the relationship. You have posted the mapping files but not the code you are actually trying to run. My guess is a combination of your wrongly placed cascades and failure to manage both sides of the relationship are causing this problem. Also remember that hibernate does things in a particular order inserts are done before deletes. This is done to avoid key violations but sometimes when it is all in one transaction you need to override this behavior and use flush to make sure things happen in the proper order. One other thing to remember is deleting something out of the database does not remove it from a list. You must do that. Managing the in memory objects are also the applications job.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic