wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes deleting causes : not-null property references a null or transient value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "deleting causes : not-null property references a null or transient value" Watch "deleting causes : not-null property references a null or transient value" New topic
Author

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

taylor kiani
Greenhorn

Joined: Aug 17, 2012
Posts: 15
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

Joined: Apr 06, 2010
Posts: 4375
    
    8

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

Joined: Mar 07, 2010
Posts: 1648
    
    7

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.


[How To Ask Questions][Read before you PM me]
taylor kiani
Greenhorn

Joined: Aug 17, 2012
Posts: 15
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

Joined: Mar 07, 2010
Posts: 1648
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: deleting causes : not-null property references a null or transient value