-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: org.hibernate.id.IdentifierGenerationException
PostPosted: Thu Oct 07, 2010 1:26 pm 
Newbie

Joined: Tue Sep 28, 2010 6:12 pm
Posts: 2
Hello,

hopefully somebody can help me in this problem. It took me a lot of time until now
and I'm still unable to figure out where the problem is.

I'm trying to persist 6 entities simultaneously when calling persist for a Booking entity.
This behavior is the expected one (in the mentioned order):

1. Persist new User entity
2. Persist new UserInfo entity
3. Persist new Customer entity
4. Persist new Property Period entity
5. Persist new Property Period Booked entity
6. Persist new Booking

Unfortunately this is the Hibernate console output:

Code:
01:15:34,936 INFO  [STDOUT] Hibernate:
    insert
    into
        user
        (password, username)
    values
        (?, ?)
01:15:34,936 INFO  [STDOUT] Hibernate:
    insert
    into
        customer
        (regularCustomer, user_id)
    values
        (?, ?)
01:15:34,936 INFO  [STDOUT] Hibernate:
    insert
    into
        property_period
        (endDate, groupCode, property_id, startDate)
    values
        (?, ?, ?, ?)
01:15:34,936 INFO  [STDOUT] Hibernate:
    insert
    into
        property_period_booked
        (property_period_id)
    values
        (?)
01:15:34,936 INFO  [STDOUT] Hibernate:
    insert
    into
        booking
        (bookingDate, user_id, number, property_period_id)
    values
        (?, ?, ?, ?)




As you can see, UserInfo is not being persisted! Why?!


I prepared a document with more details about my Hibernate mappings:

http://0182.info/Hibernate_Mapping.pdf


Thanks a lot in advance!


Last edited by diver5ity on Fri Oct 08, 2010 10:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Strange behavior when trying to persist an entity
PostPosted: Fri Oct 08, 2010 3:55 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
As first thing I would try to define also cascade = {CascadeType.PERSIST} on the @OneToOne association in in UserInfo.java


Top
 Profile  
 
 Post subject: Re: Strange behavior when trying to persist an entity
PostPosted: Fri Oct 08, 2010 7:49 am 
Newbie

Joined: Tue Sep 28, 2010 6:12 pm
Posts: 2
I just realized that I do not even get the SQL INSERTs any more :-(
As per my mappings described in the PDF attachment, it gives me this
error instead:

Code:
javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property: user


Unfortunately, I do not know how to get the INSERTs back.

@pb00067:
Thank you. I just tried to put cascade there, but it still gives the error message
above.


Does anybody know what may be the reason for that error?


Thanks a lot for any help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.