Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.6ga
Mapping documents:
<class name="com.colorful.earthbeats.beans.User" table="users">
<id name="userid" type="long" column="userid" >
<generator class="native" />
</id>
...
<!-- encrypt the password for inserts updates. -->
<sql-insert>INSERT INTO users (userid, ..., password,...) values (?, ?, AES_ENCRYPT(?,'&key;'),...);</sql-insert>
<sql-update>UPDATE ... where userid = ?;</sql-update>
</class>
NOTE: The order of the parameters here matches the order given by the generated hibernate debug output.
Code between sessionFactory.openSession() and session.close():
sessionFactory.getCurrentSession().saveOrUpdate(user);
Full stack trace of any exception that occurs:
%org.hibernate.exception.GenericJDBCException: could not insert: [com.colorful.earthbeats.
beans.User]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateC
onverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43
)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturni
ngDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPer
sister.java:2163)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPer
sister.java:2643)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAct
ion.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(Abstra
ctSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEvent
Listener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractS
aveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrReq
uestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(Defa
ultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(De
faultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(Default
SaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at com.colorful.earthbeats.dao.UserDAO.persistUser(UserDAO.java:68)
at com.colorful.earthbeats.dao.UserDAO$$FastClassByCGLIB$$bdacca17.invoke(<generat
ed>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJo
inpoint(Cglib2AopProxy.java:693)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflective
MethodInvocation.java:139)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Trans
actionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflective
MethodInvocation.java:161)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.inte
rcept(Cglib2AopProxy.java:628)
at com.colorful.earthbeats.dao.UserDAO$$EnhancerByCGLIB$$8db0cdbb.persistUser(<gen
erated>)
at com.colorful.earthbeats.servlet.RegisterConfirmServlet.doPost(RegisterConfirmSe
rvlet.java:133)
at com.colorful.earthbeats.servlet.RegisterConfirmServlet.doGet(RegisterConfirmSer
vlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil
terChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain
.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
175)
at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve
.java:51)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.ja
va:433)
at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(Ger
onimoStandardContext.java:396)
at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBefore
AfterValve.java:47)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10
9)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:88
9)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6
90)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Statement parameter 15 not set.
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.ja
va:1031)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.
java:676)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
at org.tranql.connector.jdbc.PreparedStatementHandle.executeUpdate(PreparedStateme
ntHandle.java:103)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(I
dentityGenerator.java:73)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturni
ngDelegate.java:33)
... 47 more
Name and version of the database you are using:
MySql 5 on linux amd 64
The generated SQL (show_sql=true):
10:57:36,318 DEBUG [AbstractEntityPersister] Snapshot select: select user_.userid, user_.
email as email5_, user_.name as name5_, user_.payPalEmail as payPalEm4_5_, user_.password
as password5_, user_.regType as regType5_, user_.about as about5_, user_.city as city5_, u
ser_.state as state5_, user_.country as country5_, user_.fanWeb as fanWeb5_, user_.fanEmai
l as fanEmail5_, user_.allowsEmail as allowsE13_5_, user_.dateAdded as dateAdded5_, user_.
dateModified as dateMod15_5_ from users user_ where user_.userid=?
10:57:36,319 DEBUG [AbstractEntityPersister] Insert 0: INSERT INTO users (userid, payPalE
mail, password, regType, about, city, state, country, fanWeb, fanEmail, allowsEmail, dateA
dded, dateModified, email, name) values (?, ?, AES_ENCRYPT(?,'SecretKey'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
10:57:36,320 DEBUG [AbstractEntityPersister] Update 0: UPDATE users set email=?, name=?,
payPalEmail=?, password=AES_ENCRYPT(?,'SecretKey'), regType=?
, about=?, city=?, state=?, country=?, fanWeb=?, fanEmail=?, allowsEmail=?, dateAdded=?, d
ateModified=? where userid = ?;
10:57:36,320 DEBUG [AbstractEntityPersister] Delete 0: delete from users where userid=?
10:57:36,321 DEBUG [AbstractEntityPersister] Identity insert: INSERT INTO users (userid,
payPalEmail, password, regType, about, city, state, country, fanWeb, fanEmail, allowsEmail
, dateAdded, dateModified, email, name) values (?, ?, AES_ENCRYPT(?,'SecretKey'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
Greetings:
I recently needed to change the primary key in my user table from a String to a unique auto increment long value. This value is the primary key. Since then, I have been unable to save a new item into the database. My User class defines the following unique id and contains the getter and setters.
public calss User implements Serializable {
...
private long userid = 0; //unique id for the user.
public long getUserid(){
return userid;
}
public void setUserid(long userid){
this.userid = userid;
}
...
}
Can anyone on this forum determine why I might be getting the exception above?
Any insight is appreciated.
Thanks.
Bill.