Question

On simultaneous request "object references an unsaved transient instance" error problem

Asked by: TheFACTORY_Max

Hello experts,

I have yet another hibernate question, I have an application that works with hibernate + spring MVC + struts. The problem I am having is with, I think, the sessions and detached objects.

When I test the application with one user it works flawlessly, however I have now started some stress testing using JMeter which can simulate as many simultaneous visits as you want, while trying this with 10 simultaneous visits at the time it gives an hibernate error every now and then.
The error given on the page is the following:

javax.servlet.ServletException: org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course

The stack gives this as error:
object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course

and refers to a very simple query in the GolferTypeDAO which goes wrong:
ArrayList results = (ArrayList)getHibernateTemplate().find("from GolferType where course = ? and title='Guest'", course);
(where course is a reference to a 'Course' object retrieved earlier in the same request)

As you can see I use the getHibernateTemplate helper class http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/orm/hibernate/HibernateTemplate.html
The spring application context holds the SessionFactory and gives this to the available DAO's, where the getHibernateTemplate handles the sessions from.

I've searched the error and found many stories telling about the sessionfactory, sessions, transactions and different patterns (such as the session-per-request, session-per-request-with-detached-objects, session-per-conversation , open-session-in-view-pattern)

Firstly I am not exactly sure why it gives me this error, I think it is because in one request I retrieve a 'Course' object and in this same request I use this to retrieve a 'GolferType' object using an association to a 'Course' object. With many simultaneous requests at the same time the first retrieved 'Course' object becomes detached for some reason and can't be used again in a query then?
This is easily solved by using the ID's in the query but It does not feel good as this is more of a workaround instead of actually solving the problem (which probably will come back somewhere else)

Could you advise me on which way to go in order to solve the problem?
All relevant code is below and I will give any addition information if needed.


Thanks in advance,
Max

------------------------------------------------------- applicationContext.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    
    <!-- Hibernate (persistence) -->
    
    <bean id="golfOnlineDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
         --censored--
</bean>
 
    <bean id="golfOnlineSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="golfOnlineDataSource"/>
        <property name="mappingResources">
            <list>
                <value>com/GolfOnline/Hibernate/Course.hbm.xml</value>
                <value>com/GolfOnline/Hibernate/GolferType.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.current_session_context_class">thread</prop>
                <prop key="hibernate.connection.pool_size">0</prop>
                <prop key="hibernate.dbcp.maxActive">15</prop>
                <prop key="hibernate.dbcp.maxIdle">5</prop>
                <prop key="hibernate.dbcp.maxWait">120000</prop>
                <prop key="hibernate.dbcp.whenExhaustedAction">1</prop>
                <prop key="hibernate.dbcp.testOnBorrow">true</prop>
                <prop key="hibernate.dbcp.testOnReturn">true</prop>
                <prop key="hibernate.dbcp.validationQuery">--censored--</prop>
                <prop key="hibernate.dbcp.ps.maxActive">0</prop>
                <prop key="hibernate.dbcp.ps.maxIdle">0</prop>
                <prop key="hibernate.dbcp.ps.maxWait">-1</prop>
                <prop key="hibernate.dbcp.ps.whenExhaustedAction">2</prop>
            </props>
        </property>
    </bean>
    
    <bean id="golfOnlineTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="golfOnlineSessionFactory"/>
        </property>
    </bean>
    
    <!-- Service objects -->
    <bean id="courseService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">	
        <property name="transactionManager"><ref local="golfOnlineTransactionManager"/></property>
        <property name="target"><ref local="courseServiceTarget"/></property>
        <property name="transactionAttributes">
            <props>
                <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="check*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="add*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="delete*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>
    
    <!-- Service target objects -->
    <bean id="courseServiceTarget" class="com.GolfOnline.Services.CourseServiceImpl">
        <property name="courseDAO"><ref local="courseDAO"/></property>
        <property name="golferTypeDAO"><ref local="golferTypeDAO"/></property>
    </bean>
    
    <!-- DAO objects -->
    <bean id="courseDAO" class="com.GolfOnline.DAOs.CourseDAOImpl">
        <property name="sessionFactory" ref="golfOnlineSessionFactory"/>
    </bean>
    <bean id="golferTypeDAO" class="com.GolfOnline.DAOs.GolferTypeDAOImpl">
        <property name="sessionFactory" ref="golfOnlineSessionFactory"/>
    </bean>
    
</beans>
 
------------------------------------------------------- course.hbm
 
<?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.GolfOnline.Beans.Course" table="tbl_Course">
    <id column="cr_ID" name="id" type="short">
      <generator class="native"/>
    </id>
    <property column="cr_Name" name="name"/>
  </class>
</hibernate-mapping>
 
------------------------------------------------------- golfertype.hbm
 
<?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.GolfOnline.Beans.GolferType" table="tbl_GolferType">
    <id column="gt_ID" name="id" type="short">
      <generator class="native"/>
    </id>
    <many-to-one class="com.GolfOnline.Beans.Course" column="gt_Course_cr_ID" name="course"/>
    <property column="gt_Title" name="title"/>
  </class>
</hibernate-mapping>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-03-27 at 06:32:37ID24270970
Tags

hibernate

,

spring

,

struts

,

session

,

transient

,

unsaved

Topics

Java Programming Language

,

Spring

,

J2EE Frameworks

Participating Experts
1
Points
0
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. weblogic app server support struts, spring framework,hi…
    weblogic app server support struts, spring framework,hibernate?
  2. Struts, Spring and Hibernate tutorial using MyEClipse
    Hi, there! I am looking for documents, tutorial for using Struts, Spring and Hibernte together. And the IDE should be MyEclipse. With best regards, Juhani
  3. Over Engineered? Hibernate+SPRING+STRUTS+JSTL
    I understand it's been a while in the market that the combination among SPRING, Hibernate, Sturct, JSTL to come out with a fantastic application. There are lot of user complaining about the combination is over engineered or it's not suitable for the beginner to use as it's v...
  4. Any good Spring-Struts-Hibernate tutorials or lessions ?
    Hi, I'm new to Spring-Struts-Hibernate, does anyone know any spring-struts-hiberate sites or tutorials that have sample project that I can learn from, any recommendations ? Thanks so much, noijet
  5. object references an unsaved transient instance - save th…
    Hi, there! I am using hibernate and spring 2, and its UI framework is struts2. I have an Item class, it has association with User and Category. User could sell item, so item has an foreign key from user. Everything goes fine in unit test, so it is not hbm configuration err...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: objectsPosted on 2009-03-27 at 20:15:06ID: 24007092

> (where course is a reference to a 'Course' object retrieved earlier in the same request)

are you sure

 

by: objectsPosted on 2009-03-27 at 20:16:18ID: 24007094

can you post the full stack trace

 

by: TheFACTORY_MaxPosted on 2009-03-28 at 13:05:51ID: 24009926

Yes I am sure of that, a request comes in, the session is started, than immediately the course is retrieved using the ID which is given (and valid) in the request parameters using:

return (Course)getHibernateTemplate().get(Course.class, id);

The course's reference is saved in the session in a variable which is used from that moment on.
It is checked wether the value is not null and than immediately after that, a function is called with the course object as an argument which does the call that the stacktrace points out as the guilty call eventually ending in:

ArrayList results = (ArrayList)getHibernateTemplate().find("from GolferType where course = ? and title='Guest'", course);

causing the error.

The code snipper below displays the tomcat 6 stacktrace, note that this is from a number of simultaneous requests.

Tnx

28-mrt-2009 20:49:49 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
        at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:62)
        at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
        at org.hibernate.loader.Loader.doQuery(Loader.java:696)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.doList(Loader.java:2228)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
        at org.hibernate.loader.Loader.list(Loader.java:2120)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
        at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:856)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:843)
        at com.GolfOnline.DAOs.GolferTypeDAOImpl.getGolferTypeGuest(GolferTypeDAOImpl.java:77)
        at com.GolfOnline.Services.CourseServiceImpl.getGolferTypeGuest(CourseServiceImpl.java:847)
        at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy18.getGolferTypeGuest(Unknown Source)
        at com.GolfOnline.Servlets.GolferBookingServlet.updateCourseBookSettingsInSession(GolferBookingServlet.java:9720)
        at com.GolfOnline.Servlets.GolferBookingServlet.startNewGolfBooking(GolferBookingServlet.java:212)
        at com.GolfOnline.Servlets.GolferBookingServlet.initPage(GolferBookingServlet.java:63)
        at com.GolfOnline.Servlets.GolferBookingServlet.showPageCalendar(GolferBookingServlet.java:259)
        at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.cj.trim.trimFilter.doFilter(Unknown Source)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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:191)
        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:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
28-mrt-2009 20:49:49 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
        at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:62)
        at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
        at org.hibernate.loader.Loader.doQuery(Loader.java:696)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.doList(Loader.java:2228)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
        at org.hibernate.loader.Loader.list(Loader.java:2120)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
        at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:856)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:843)
        at com.GolfOnline.DAOs.GolferTypeDAOImpl.getGolferTypeGuest(GolferTypeDAOImpl.java:77)
        at com.GolfOnline.Services.CourseServiceImpl.getGolferTypeGuest(CourseServiceImpl.java:847)
        at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy18.getGolferTypeGuest(Unknown Source)
        at com.GolfOnline.Servlets.GolferBookingServlet.updateCourseBookSettingsInSession(GolferBookingServlet.java:9720)
        at com.GolfOnline.Servlets.GolferBookingServlet.startNewGolfBooking(GolferBookingServlet.java:212)
        at com.GolfOnline.Servlets.GolferBookingServlet.initPage(GolferBookingServlet.java:63)
        at com.GolfOnline.Servlets.GolferBookingServlet.showPageCalendar(GolferBookingServlet.java:259)
        at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.cj.trim.trimFilter.doFilter(Unknown Source)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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:191)
        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:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
28-mrt-2009 20:49:50 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
        at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:62)
        at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
        at org.hibernate.loader.Loader.doQuery(Loader.java:696)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.doList(Loader.java:2228)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
        at org.hibernate.loader.Loader.list(Loader.java:2120)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
        at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:856)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:843)
        at com.GolfOnline.DAOs.GolferTypeDAOImpl.getGolferTypeGuest(GolferTypeDAOImpl.java:77)
        at com.GolfOnline.Services.CourseServiceImpl.getGolferTypeGuest(CourseServiceImpl.java:847)
        at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy18.getGolferTypeGuest(Unknown Source)
        at com.GolfOnline.Servlets.GolferBookingServlet.updateCourseBookSettingsInSession(GolferBookingServlet.java:9720)
        at com.GolfOnline.Servlets.GolferBookingServlet.startNewGolfBooking(GolferBookingServlet.java:212)
        at com.GolfOnline.Servlets.GolferBookingServlet.initPage(GolferBookingServlet.java:63)
        at com.GolfOnline.Servlets.GolferBookingServlet.showPageCalendar(GolferBookingServlet.java:259)
        at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.cj.trim.trimFilter.doFilter(Unknown Source)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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:191)
        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:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
28-mrt-2009 20:49:52 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.GolfOnline.Beans.Course
        at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
        at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
        at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:62)
        at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
        at org.hibernate.loader.Loader.doQuery(Loader.java:696)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.doList(Loader.java:2228)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
        at org.hibernate.loader.Loader.list(Loader.java:2120)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
        at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:856)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:843)
        at com.GolfOnline.DAOs.GolferTypeDAOImpl.getGolferTypeGuest(GolferTypeDAOImpl.java:77)
        at com.GolfOnline.Services.CourseServiceImpl.getGolferTypeGuest(CourseServiceImpl.java:847)
        at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy18.getGolferTypeGuest(Unknown Source)
        at com.GolfOnline.Servlets.GolferBookingServlet.updateCourseBookSettingsInSession(GolferBookingServlet.java:9720)
        at com.GolfOnline.Servlets.GolferBookingServlet.startNewGolfBooking(GolferBookingServlet.java:212)
        at com.GolfOnline.Servlets.GolferBookingServlet.initPage(GolferBookingServlet.java:63)
        at com.GolfOnline.Servlets.GolferBookingServlet.showPageCalendar(GolferBookingServlet.java:259)
        at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.cj.trim.trimFilter.doFilter(Unknown Source)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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:191)
        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:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:

Select allOpen in new window

 

by: objectsPosted on 2009-03-30 at 04:07:57ID: 24017642

weird, not sure what the prob is. need a small example that I can run to reproduce the problem

 

by: TheFACTORY_MaxPosted on 2009-04-02 at 03:47:56ID: 24048276

Sorry it took a while, had to prepare you a proper example and it had to be done inbetween other stuff.

I made the example as simple and small as possible but due to the spring-struts-hibernate combination the project still drags along some MB's from the included libraries.

http://www.maxvandenboom.nl/testprogram.html, holds the example sourse (Netbeans project), database SQL and JMeter (and it's test plan to reproduce the error)

Thanks for looking at it!!

 

by: TheFACTORY_MaxPosted on 2009-04-27 at 01:49:24ID: 24239822

Could you keep this question open a little bit longer so the reference in the re-post of this question will stay valid? Repost of this question:
http://www.experts-exchange.com/Programming/Languages/Java/Q_24348230.html#a24239784

If that one also does not give an answer you might as well delete both at the same time.

 

by: TheFACTORY_MaxPosted on 2009-05-11 at 01:22:03ID: 24352415

Re-post of this question does come with a solution:
http://www.experts-exchange.com/Programming/Languages/Java/Q_24348230.html

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...