Hibernate version:2.1.7
Mapping documents:
[code]<class name="Message" table="MESSAGE">
<id name="messageid" column="MESSAGEID" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">SEQ_MESSAGE</param>
</generator>
</id>
<property name="messagecontent" column="MESSAGECONTENT" type="java.lang.String" />
</class>
[code]
Code between sessionFactory.openSession() and session.close():
[code]
Session session = HibernateSessionFactory.currentSession();
String querystring = "SELECT msg FROM Message as msg where messageid= :msgid";
Query query = session.createQuery(querystring);
query.setLong("msgid", messageid.longValue());
List list = query.list();
if (list.size() > 0) {
Message message = (Message) list.get(0);
strResult = message.getMessage();
}
[code]
Name and version of the database you are using:
Oracle 9.0.2.5
I read this forum about clob's and Oracle and was amazed when I read that using the OCI driver and the new oracle 10 driver (ojdbc14.jar) would make your life easy. So I changed my configuration and was amazed to see I could easily store a large XML message as a string into my CLOB column.
But then the next step is retrieving that column again. Unfortunately I do not seem to get that working.
The column is mapped to a java.lang.String, as indicated in this forum. That works for storing the column, but when the object is retrieved, I keep getting a null value, although the database shows the value is not null!
Abstract generated class:
[code]
public abstract class AbstractRismessage
implements Serializable
{
/** The composite primary key value. */
private java.lang.Long messageid;
/** The value of the simple xmlmessage property. */
private java.lang.String messagecontent;
public java.lang.String getMessagecontent()
{
return this.messagecontent;
}
public void setMessagecontent(java.lang.String content)
{
this.messagecontent = content;
}
}
[code]
The hybernate configuration was changed to:
[code]
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.use_streams_for_binary"> true</property>
<property name="SetBigStringTryClob">true</property>
[code]
And I am using the OCI driver.
So using the the setMessagecontent method works like a dream after changing my hybernate configuration. But using the getMessagecontent method always returns a null.
Does anyone have an idea? I'd rather not implement the Interceptor stuff if I don't need to.
Thanks for any suggestions...
|