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. --
|