Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hello all:
I have just finished upgrading to Hibernate 3.0 successfully, however; whenI run my application the primary key is set for the field "comment" of type "text" (which is defined as Clob in query). If I run the application using hibernate 2.1.8, the field is reterieved properly and is displayed corrently but with Hibernate 3.0 the field is set to primary key !!!
Hibernate version:3.0
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="iadm.readme.model">
<class name="iadm.readme.model.Comment" table="README.COMMENT" >
<id name="id" column="COMMENT_ID" type="long" >
<generator class="native"/>
</id>
<property name="author" type="string" column="AUTHOR" length="50" not-null="true"/>
<property name="title" type="string" column="TITLE" length="80" not-null="true"/>
<property name="comment" type="text" column="COMMENT" not-null="true"/>
<property name="visible" type="yes_no" column="VISIBLE" not-null="true"/>
<property name="created" column="CREATED_TIMESTAMP" type="timestamp" not-null="true" update="false"/>
<property name="modified" column="MODIFIED_TIMESTAMP" type="timestamp" not-null="true"/>
<many-to-one name="category" column="CATEGORY_ID" class="iadm.readme.model.Category" not-null="true" fetch="join"/>
<set name="releases" cascade="all-delete-orphan" inverse="true" batch-size="100" >
<key>
<column name="COMMENT_ID" not-null="true" />
</key>
<one-to-many class="iadm.readme.model.Release" />
</set>
</class>
<query name='comment'> <![CDATA[from Comment c left join fetch c.releases r where c.id = :id ]]></query>
<query name='commentByCategoryId'> <![CDATA[from Comment c left join fetch c.releases r left join fetch c.category where c.category.id = :id]]></query>
<query name='visibleCommentByCategoryId'> <![CDATA[from Comment c left join fetch c.releases r left join fetch c.category where c.category.id = :id and c.visible = :visible1 and c.category.visible = :visible2 ]]></query>
</hibernate-mapping>
Function called:
public Collection getCommentsByVisibilityAndCategoryId(long categoryId,
boolean commentVisible, Session session) {
Collection result = null;
String visible = (commentVisible) ? "Y" : "N";
try {
Collection comments = session.getNamedQuery(
"visibleCommentByCategoryId").setLong("id", categoryId)
.setString("visible1", visible).setString("visible2", "Y")
.list();
result = new HashSet(comments);
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
return result;
}
Name and version of the database you are using: DB2 8.2