-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem inserting a new record
PostPosted: Thu Jan 13, 2005 10:22 pm 
Newbie

Joined: Thu Jan 13, 2005 10:15 pm
Posts: 3
Location: San Salvador
Hi, I have this problem inserting new records, i´m a newbie on hibernate.
I made my table in oracle, the primary key is a VARCHAR2(10) called COD_TIPO_CUENTA, I allready debuged the Action class and the properties are comming rigth from the form. I can´t realize what is happenning. Please help me.

Hibernate version: hibernate2.jar

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="sv.com.equifax.gestor.model">
<class name="TiposCuenta" table="TIPOS_CUENTA">
<id
column="COD_TIPO_CUENTA"
name="CodTipoCuenta"
type="string"
>
<generator class="vm" />
</id>
<property
column="DESCRIPCION"
length="200"
name="Descripcion"
not-null="true"
type="string"
/>
<set inverse="true" name="OperacionesInternacionalesSet">
<key column="COD_TIPO_CUENTA" />
<one-to-many class="OperacionesInternacionales" />
</set>
<set inverse="true" name="DepositosInversionesSet">
<key column="COD_TIPO_CUENTA" />
<one-to-many class="DepositosInversiones" />
</set>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
TiposCuentaVariosForm pForm = (TiposVariosForm) form;
TiposCuenta p = new TiposCuenta();
p.setCodTipoCuenta(pForm.getCodigo());
p.setDescripcion(pForm.getDescripcion());

Full stack trace of any exception that occurs:
net.sf.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short
at net.sf.hibernate.id.IdentifierGeneratorFactory.createNumber(IdentifierGeneratorFactory.java:97)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:774)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at sv.com.equifax.gestor.catalogos.TiposCuentaAction.execute(TiposCuentaAction.java:33)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)


Name and version of the database you are using:
ORACLE 9i


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 10:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The error in the stack trace explains it clearly - eg generator requires a long when your using a string.

Also, you need to use the transaction API (can be managed), it appears you were not doing so.

I strongly suggest you read the docs more closely and try some simple examples before getting into relationships etc.

Maybe read this as a starter http://www.systemmobile.com/articles/IntroductionToHibernate.html
look at the code as well.


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