-->
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.  [ 7 posts ] 
Author Message
 Post subject: Oracle and hibernate got ORA-01461 errors
PostPosted: Mon May 29, 2006 7:35 am 
Newbie

Joined: Mon May 29, 2006 7:06 am
Posts: 5
Caused by: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

Said it's because of charset, but first, there is no LONG column in the table, second, I just use the thin driver, which was works normal in get data from db, including the unicode chars, third, I tried both jdbc in hibernate.cfg.xml and just jndi in hibernate.cfg.xml, the same.

Hibernate version: 3.0.4 and 3.1.3

Mapping documents:
Code:
<?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>
  <class name="com.ccti.user.User" table="users" dynamic-update="true" optimistic-lock="version">
    <id unsaved-value="null" name="userID" column="F_UserID" type="long">
      <generator class="sequence">
        <param name="sequence">SEQ_USERID</param>
      </generator>
    </id>
    <property name="userName" column="F_UserName" type="string" not-null="true" update="false" />
    <property name="userPass" column="F_UserPass" type="string" not-null="true" />
    <property name="realName" column="F_RealName" type="string" not-null="true" />
    <property name="sex" column="F_Sex" type="string" />
    <property name="lastvisit" column="F_Lastvisit" type="timestamp" />
    <many-to-one name="department" class="com.ccti.department.Department" column="F_DepartID" />
    <many-to-one name="role" class="com.ccti.role.Role" column="F_RoleID" />
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
    try {
      beginTransaction();
      session.update(user);
      endTransaction(true);
    } catch (Exception err) {
      return false;
    }


Full stack trace of any exception that occurs:

Quote:
org.hibernate.util.JDBCExceptionReporter 2006-05-29 12:06:57,337 -- ERROR -- ORA-01461: can bind a LONG value only for insert into a LONG column

org.hibernate.event.def.AbstractFlushingEventListener 2006-05-29 12:06:57,337 -- ERROR -- Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not update: [com.ccti.user.User#1]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2222)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
at com.ccti.base.HibernateBase.endTransaction(HibernateBase.java:54)
at com.ccti.user.UserHibernate.updateUser(UserHibernate.java:57)
at com.ccti.user.UserImpl.updateUser(UserImpl.java:56)
at com.ccti.web.LoginController.handleRequest(LoginController.java:97)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:386)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:355)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:188)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507)
at com.caucho.util.ThreadPool.run(ThreadPool.java:433)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:158)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:685)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1138)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3018)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3090)
at com.caucho.sql.UserPreparedStatement.executeUpdate(UserPreparedStatement.java:117)
at com.caucho.sql.UserPreparedStatement.executeUpdate(UserPreparedStatement.java:117)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2204)
... 31 more


Name and version of the database you are using:
Oracle 9.0.1 & 9.2.0

The generated SQL (show_sql=true):
update users set F_UserPass=?, F_RealName=?, F_Sex=?, F_Lastvisit=?, F_DepartID=?, F_RoleID=? where F_UserID=?

Debug level Hibernate log excerpt:
Quote:
org.hibernate.persister.entity.AbstractEntityPersister 2006-05-29 12:06:57,287 -- DEBUG -- Updating entity: [com.ccti.user.User#1]
org.hibernate.jdbc.AbstractBatcher 2006-05-29 12:06:57,287 -- DEBUG -- about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
org.hibernate.jdbc.ConnectionManager 2006-05-29 12:06:57,287 -- DEBUG -- opening JDBC connection
org.hibernate.SQL 2006-05-29 12:06:57,287 -- DEBUG -- update users set F_UserPass=?, F_RealName=?, F_Sex=?, F_Lastvisit=?, F_DepartID=?, F_RoleID=? where F_UserID=?
org.hibernate.jdbc.AbstractBatcher 2006-05-29 12:06:57,287 -- DEBUG -- preparing statement
org.hibernate.persister.entity.AbstractEntityPersister 2006-05-29 12:06:57,287 -- DEBUG -- Dehydrating entity: [com.ccti.user.User#1]
org.hibernate.type.StringType 2006-05-29 12:06:57,287 -- DEBUG -- binding '418EF1B3EB9B3AB2' to parameter: 1
org.hibernate.type.StringType 2006-05-29 12:06:57,287 -- DEBUG -- binding '系统管理员' to parameter: 2
org.hibernate.type.StringType 2006-05-29 12:06:57,287 -- DEBUG -- binding '男' to parameter: 3
org.hibernate.type.TimestampType 2006-05-29 12:06:57,287 -- DEBUG -- binding '2006-05-29 12:06:57' to parameter: 4
org.hibernate.engine.IdentifierValue 2006-05-29 12:06:57,287 -- DEBUG -- id unsaved-value strategy NULL
org.hibernate.type.LongType 2006-05-29 12:06:57,287 -- DEBUG -- binding '1' to parameter: 5
org.hibernate.engine.IdentifierValue 2006-05-29 12:06:57,287 -- DEBUG -- id unsaved-value strategy NULL
org.hibernate.type.LongType 2006-05-29 12:06:57,287 -- DEBUG -- binding '1' to parameter: 6
org.hibernate.type.LongType 2006-05-29 12:06:57,287 -- DEBUG -- binding '1' to parameter: 7
org.hibernate.jdbc.AbstractBatcher 2006-05-29 12:06:57,307 -- DEBUG -- about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
org.hibernate.jdbc.AbstractBatcher 2006-05-29 12:06:57,307 -- DEBUG -- closing statement
org.hibernate.jdbc.ConnectionManager 2006-05-29 12:06:57,307 -- DEBUG -- skipping aggressive-release due to flush cycle
org.hibernate.util.JDBCExceptionReporter 2006-05-29 12:06:57,327 -- DEBUG -- could not update: [com.ccti.user.User#1] [update users set F_UserPass=?, F_RealName=?, F_Sex=?, F_Lastvisit=?, F_DepartID=?, F_RoleID=? where F_UserID=?]
java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column


Last edited by cytown on Mon May 29, 2006 7:44 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 7:43 am 
Newbie

Joined: Mon May 29, 2006 7:06 am
Posts: 5
p.s.

when I use it with oracle 9.0.1, the above works without errors, but the userpass field was change with bad char in front of it, like:
'@!#EF1B3EB9B3AB2', '*&*EF1B3EB9B3AB2', most is not the a-Z chars, when I make the field update=false, the disaster accord to realname field......

also, the select clauses were always worked well.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 2:26 am 
Newbie

Joined: Mon May 29, 2006 7:06 am
Posts: 5
somebody know?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 05, 2006 3:38 am 
Newbie

Joined: Mon May 29, 2006 7:06 am
Posts: 5
go up again.


Top
 Profile  
 
 Post subject: Pure JDBC test?
PostPosted: Sat Jun 10, 2006 2:47 pm 
Newbie

Joined: Sat May 06, 2006 8:08 pm
Posts: 4
Can you create a pure JDBC test that reproduces the problem? You should be able to cut and paste the hibernate sql into a simple jdbc test program and bind the same values. If that succeedes, then hibernate is part of the problem. If it fails then either there is a problem in the JDBC driver or both the test and Hibernate are not executing the right JDBC code.

Does your database characterset support the multibyte characters in the user name? Is the user name column an NCHAR column. If so, perhaps Hibernate is not handling the setFormOfUse call correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 10:04 pm 
Newbie

Joined: Mon May 29, 2006 7:06 am
Posts: 5
dsurber, first, all jdbc works fine, of course with the same value. Second, yes I am using the multibyte characters in database, real_name and sex is multibyte, but it update correct with hibernate......

Really strange......


Top
 Profile  
 
 Post subject: Re: Oracle and hibernate got ORA-01461 errors
PostPosted: Fri Feb 02, 2007 5:30 am 
Newbie

Joined: Thu Feb 01, 2007 11:59 am
Posts: 1
Hi cytown,

Did you solve your problem ?
I'm facing exactly the same situation and I was wondering if you managed to find a solution.

Thanks in advance for you input.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.