-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cannot save a child with UUID as primary
PostPosted: Sat Mar 31, 2007 4:12 pm 
Newbie

Joined: Fri May 27, 2005 3:19 pm
Posts: 18
The problem is that a child with primary as uuid is not being inserted into the database, though DEBUG log says it is being saved. As soon as I replace uuid generator with native, and make changes from String to Long, and change the database field from VARCHAR to BIGINT with Autoincrement, the record is being inserted without any problems. I am out of ideas at this point, any help is appreciated, thanks.

Hibernate version: 3.2.2

Mapping documents:

--------------------
<hibernate-mapping>
<class name="com.portal.domain.UserProfile" table="user_profile">
<id name="userProfileId" type="java.lang.Long">
<column name="user_profile_id" />
<generator class="identity"/>
</id>
<bag name="userProfileActivations" inverse="true" cascade="all-delete-orphan">
<key column="user_profile_id"/>
<one-to-many class="com.portal.domain.UserProfileActivation"/>
</bag>
</class>
</hibernate-mapping>


---------------------
<hibernate-mapping>
<class name="com.portal.domain.UserProfileActivation" table="user_profile_activation">
<id name="userProfileActivationId" type="java.lang.String">
<column name="user_profile_activation_id" />
<generator class="uuid.hex" />
</id>
<many-to-one name="userProfile" class="com.portal.domain.UserProfile" fetch="select">
<column name="user_profile_id" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

UserProfile userProfile = new UserProfile();
UserProfileActivation userProfileActivation = new UserProfileActivation();
userProfileActivation.setUserProfile(userProfile);
userProfile.getUserProfileActivations().add(userProfileActivation);

....DAO saves the transient instance userProfile

Name and version of the database you are using: MySQL 5.0.27


The generated SQL (show_sql=true):
Hibernate: insert into user_profile (profile_type_id, profile_status_id, username, userpass, email, dob, last_name, first_name) values (?,
?, ?, ?, ?, ?, ?, ?)


Debug level Hibernate log excerpt:

DEBUG - org.hibernate.engine.Cascades - cascade ACTION_SAVE_UPDATE for collection: com.portal.domain.UserProfile.userProfileActivations --
DEBUG - org.hibernate.engine.Cascades - cascading to saveOrUpdate: com.portal.domain.UserProfileActivation --
DEBUG - org.hibernate.event.def.AbstractSaveEventListener - transient instance of: com.portal.domain.UserProfileActivation --
DEBUG - org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance --
DEBUG - org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 402881e511a995890111a995992e0001, using strategy: org.hibernate.id.UUIDHexGenerator --
DEBUG - org.hibernate.event.def.AbstractSaveEventListener - saving [com.portal.domain.UserProfileActivation#402881e511a995890111a995992e0001] --
DEBUG - org.hibernate.engine.Cascades - done cascade ACTION_SAVE_UPDATE for collection: com.portal.domain.UserProfile.userProfileActivations --
DEBUG - org.hibernate.engine.Cascades - deleting orphans for collection: com.portal.domain.UserProfile.userProfileActivations --
DEBUG - org.hibernate.engine.Cascades - done deleting orphans for collection: com.portal.domain.UserProfile.userProfileActivations --
DEBUG - org.hibernate.engine.Cascades - done processing cascade ACTION_SAVE_UPDATE for: com.portal.domain.UserProfile --
DEBUG - com.portal.domain.UserProfileDAO - save successful --
DEBUG - com.portal.hibernate.util.HibernateUtil - Closing Session of this thread. --


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 4:45 pm 
Newbie

Joined: Fri May 27, 2005 3:19 pm
Posts: 18
Still having this problem, the DEBUG says that the record is being saved, however, no INSERT statement is generated and record is not saved to DB. Any ideas? Thank you.


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