-->
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.  [ 4 posts ] 
Author Message
 Post subject: Maping String type to Number type
PostPosted: Tue Oct 10, 2006 3:32 pm 
Newbie

Joined: Tue Aug 15, 2006 10:02 am
Posts: 9
Hibernate version:
3.1.3

Spring Version:
2.0

Mapping documents:

Code:
<hibernate-mapping package="domain" default-lazy="false">
    <class name="Order" table="Order">
        <id name="id" column="ORDER_ID" type="string"/>
        <property name="orderText" column="ORDER" />
        <property name="submissionDate" column="SUBMISSION_DATE" type="timestamp" />
        <property name="applicantLevel" column="CUSTOMER_LEVEL_CD" />
        <many-to-one name="customer" column="CUSTOMER_ID" class="Customer" cascade="save-update" />
    </class>
....
...

</hibernate-mapping>



Question:

The database field ORDER_ID is of type number(7) but I mapped it to string for certain reasons. Is it OK to do that? It does seems to work but when we ran the load test we do get following error every once in a while

Full stack trace of exception that occurs:

org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): domain.Order
at org.hibernate.id.Assigned.generate(Assigned.java:33)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:502)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:494)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:490)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:677)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:674)
at edu.rutgers.enterprise.elor.dao.hibernate.RecommendationDaoHibernate.saveRecommendation(RecommendationDaoHibernate.java:38)
at edu.rutgers.enterprise.elor.service.ElorServiceFacadeImpl.saveRecommendation(ElorServiceFacadeImpl.java:38)
at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:266)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy1.saveRecommendation(Unknown Source)
at edu.rutgers.enterprise.elor.web.SubmitLetterSimpleFormController.onSubmit(SubmitLetterSimpleFormController.java:47)
at org.springframework.web.servlet.mvc.SimpleFormController.onSubmit(SimpleFormController.java:356)
at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:258)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:728)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


Name and version of the database you are using:
Oracle 10g

More info

The Order id is generated by some other process and I just want to use the generated id to pull the right record and later make the update. I know there is one generator "assigned" that might be usefull in this situation but I read in the documentation that it is the default one. So I assume it is already being used.

Any help will be greatly appreciated. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 10, 2006 5:58 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Faikeeyes,

Maybe your ID property is null and the object cannot be saved? If could add this extra test and re-run your load testing ... most reproducible code problems are solvable problems :)

Marius


Top
 Profile  
 
 Post subject: how about maping String to number field
PostPosted: Wed Oct 11, 2006 9:15 am 
Newbie

Joined: Tue Aug 15, 2006 10:02 am
Posts: 9
mseritan,

You did not tell me if maping "String" to number field is OK? Please let me know thanks.


Faikeeyes.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 10:31 am 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Hi,

I am sorry I never used this mapping. You said you have to use it, so why not just give it a try. If you can read records, update and write back then you are all set.

If you are not comfortable with the approach ever after testing it you can also provide a second set of accessors. You can leave setId(), getId() to the native Integer/Long and add a setMyId(String) that converts explicitly.

Marius


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