I'm new to hibernate and this is my first post. Please tell me if I'm breaking protocol in any way.
The only post I could find with a similar issue was this one.
http://forum.hibernate.org/viewtopic.php?t=939662
I'm hoping someone has a solution for me. I'm not experiencing the issue with native generator on an int key, only with assigned generator on a char id key.
Hibernate version:
3.2
Mapping documents:
I have a MS SQl Server 2005 table with char(2) primary key and I'm using the following mapping.
<class name="Country" table="country" lazy="false">
<id column="ccode1" type="string">
<generator class="assigned" />
</id>
<property name="ccode2" type="string"/>
<property name="ccode3" type="integer"/>
<property name="continent" type="string"/>
<property name="iddn" type="string"/>
<property name="timezone" type="string"/>
</class>
Code between sessionFactory.openSession() and session.close():
When a result object is return the primary keys is null. i.e.
String cCode = "AU";
session.beginTransaction();
Country c = (Country) session.load(Country.class,cCode);
session.getTransaction().commit();
<:Country>
<CCODE1>NULL</CCODE1>
<CCODE2>AUS</CCODE2>
<CCODE3>36</CCODE3>
<CONTINENT>OC</CONTINENT>
<IDDN>61</IDDN>
<TIMEZONE>+10</TIMEZONE>
</:Country>
This also occurs using criteria query and HQL to return a List of objects.
Name and version of the database you are using:
MS SQl Server 2005
The generated SQL (show_sql=true):
Hibernate: select country0_.ccode1 as ccode1_1_0_, country0_.ccode2 as ccode2_1_0_, country0_.ccode3 as ccode3_1_0_, country0_.continent as continent1_0_, country0_.iddn as iddn1_0_, country0_.timezone as timezone1_0_ from country country0_ where country0_.ccode1=?