-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Hibernate 2.0 and CLOB
PostPosted: Fri Aug 24, 2007 4:15 pm 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
Hi I was trying to put text of size more than 4000 chars and its giving me following exception. The database type used for storing data is CLOB. I am using hibernate 2.0
Can anyone help?
08/22/2007 15:07:23.512 ERROR LoggingExceptionHandler ExecuteThread: '14' for
queue: 'weblogic.kernel.Default' - Exception reached UI
java.sql.SQLException: operation not allowed: streams type cannot be used in bat
ching
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedSta
tement.java:3999)
at weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePrep
aredStatement.addBatch(Unknown Source)
at net.sf.hibernate.impl.BatchingBatcher.addToBatch(BatchingBatcher.java
:26)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:642)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:611)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:31
)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2100)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2062)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:57)
at com.marsh.itg.csi.ui.HibernateAction.submit(HibernateAction.java:70)
at com.marsh.itg.csi.ui.CancellableAction.execute(CancellableAction.java
:28)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:480)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:142
0)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
rethrown as
net.sf.hibernate.JDBCException: Could not synchronize database state with sessio
n: operation not allowed: streams type cannot be used in batching
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2069)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:57)
at com.marsh.itg.csi.ui.HibernateAction.submit(HibernateAction.java:70)
at com.marsh.itg.csi.ui.CancellableAction.execute(CancellableAction.java
:28)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:480)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:142
0)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Caused by: java.sql.SQLException: operation not allowed: streams type cannot be
used in batching
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedSta
tement.java:3999)
at weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePrep
aredStatement.addBatch(Unknown Source)
at net.sf.hibernate.impl.BatchingBatcher.addToBatch(BatchingBatcher.java
:26)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:642)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:611)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:31
)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2100)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2062)
... 20 more
08/22/2007 15:07:23.841 INFO PropertyMessageResources ExecuteThread: '14' fo
r queue: 'weblogic.kernel.Default' - Initializing, config='org.apache.struts.tag
lib.html.LocalStrings', returnNull=true


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 26, 2007 3:45 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
Hi!

Please post the relevant part(s) of your hibernate mapping file(s).


-Kaj :)


Top
 Profile  
 
 Post subject: mapping file
PostPosted: Mon Aug 27, 2007 9:18 am 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
<property name="connection.datasource">marsh/itg/CSI</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>

<!-- This is to use C3P0, so that each request has it's own db-connection -->
<property name="c3p0.max_size">1000</property>
<property name="c3p0.min_size">1</property>
<property name="c3p0.timeout">5000</property>
<property name="c3p0.max_statements">30</property>
<property name="c3p0.idleConnectionTestPeriod">1800</property>
<property name="c3p0.maxIdleTime">7200</property>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 11:08 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
Hi!

Sorry for beeing unclear... I ment the relevant part of the file where you are mapping you tables against your javaobject, i.e. the hbm.xml file.


-Kaj :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 12:03 pm 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
<class name="com.marsh.itg.csi.ui.plan.TextAnswer" table="T_CSTAN_TEXT_ANSWER">

<id name="answerID" type="string" column="TAN_ID">
<column name="TAN_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="parentID">
<column name="TAN_PARENT_ID" sql-type="CHAR(32)" not-null="true"/>
</property>

<property name="questionID" type="integer">
<column name="TAN_QUESTION_ID" sql-type="NUMBER(8)" not-null="true"/>
</property>

<property name="textAnswer" column="TAN_ANSWER" type="com.marsh.itg.csi.hibernate.StringClobType"/>
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 12:05 pm 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
public class StringClobType extends ImmutableType
{
public Object get(ResultSet rs, String name) throws HibernateException, SQLException
{
Reader reader = rs.getCharacterStream(name);
if(reader == null)
{
return null;
}
StringBuffer sb = new StringBuffer();
try
{
char[] charbuf = new char[4096];
for(int i = reader.read(charbuf); i > 0; i = reader.read(charbuf))
{
sb.append(charbuf, 0, i);
}
}
catch(IOException e)
{
throw new SQLException(e.getMessage());
}
return sb.toString();
}

public Class returnedClass()
{
return String.class;
}

public void set(PreparedStatement st, Object value, int index)
throws SQLException
{
StringReader r = new StringReader((String) value);
st.setCharacterStream(index, r, ((String) value).length());
}

public int sqlType()
{
return Types.CLOB;
}

public String getName() { return "string"; }

public boolean hasNiceEquals()
{
return false;
}

public Class getReturnedClass()
{
return String.class;
}

public boolean equals(Object x, Object y)
{
return ObjectUtils.equals(x, y);
}

public String toXML(Object value)
{
return (String) value;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 12:12 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
Sangeeta Patel wrote:
<property name="textAnswer" column="TAN_ANSWER" type="com.marsh.itg.csi.hibernate.StringClobType"/>


Hi!

We use type="java.lang.String" for our CLOB columns. We are using Hibernate3 and Oracle.

You could try to change type for textAnswer, and let me know what happends.


-Kaj :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 12:19 pm 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
Will changing it to type=java.lang.String will work since I am using hibernate 2.0 and oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 2:33 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
Sangeeta Patel wrote:
Will changing it to type=java.lang.String will work since I am using hibernate 2.0 and oracle?


I don't know :) It work for us, but we use Hibernate 3.

If that does not work you can try type="text".

Please let me know how this works you if you try this solution.

Good luck!


-Kaj :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 3:08 pm 
Newbie

Joined: Fri Aug 24, 2007 4:07 pm
Posts: 6
kajh wrote:
Sangeeta Patel wrote:
Will changing it to type=java.lang.String will work since I am using hibernate 2.0 and oracle?


I don't know :) It work for us, but we use Hibernate 3.

If that does not work you can try type="text".

Please let me know how this works you if you try this solution.

Good luck!


-Kaj :)


This is throwing exception like data size bigger than max size for this type.....I guess this is not supported by hibernate2


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.