Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.1.5
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Putting this post just so to save some time of others. I wasted so much time on finding out what was wrong.. Changed database types etc etc... At the end, found it was some strange problem which I possibly can attribute to Hibernate.
I used to be getting the above exception and this is how it was resolved.
By looking at the next two hbm.xml snippets, nothing seems to be wrong. But the following did not work for me.
<class name="com.xxxx" table="MUser">
<meta attribute="extends">com.xxxx.SevaBaseDO</meta>
<id column="muser_ky" name="id" type="java.lang.Long">
<generator class="identity"/>
</id>
<many-to-one name="contact" class="com.xxxxMcontact" property-ref="user" cascade="all" />
-------------------------------------------------
<class name="com.xxxxxxx.Mcontact" table="MContact">
<meta attribute="extends">com.xxxxxx.SevaBaseDO</meta>
<id column="mcontact_ky" name="id" type="java.lang.Long">
<generator class="identity"/>
</id>
<many-to-one name="user" class="com.xxxxx.Muser" column="user_ky" cascade="all"/>
To make it work:
I simply changed the many-to-one to one-to-one and it worked.
<class name="com.xxxx" table="MUser">
<meta attribute="extends">com.xxxx.SevaBaseDO</meta>
<id column="muser_ky" name="id" type="java.lang.Long">
<generator class="identity"/>
</id>
<one-to-one name="contact" class="com.xxxxMcontact" property-ref="user" cascade="all" />