• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!)
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are still misusing CascadeType.REMOVE

go re-read my comments in this thread
https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic