-->
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.  [ 6 posts ] 
Author Message
 Post subject: Classcast exception on simple find
PostPosted: Thu Jan 22, 2004 6:57 am 
Beginner
Beginner

Joined: Fri Jan 02, 2004 7:07 pm
Posts: 35
I have the following:

Code:
           AccountProfile account = null;

            tx = session.beginTransaction();

            // Get the account object with the supplied masternumber
            account = (AccountProfile) session.find(
                    "from AccountProfile as account where master = ?",
                    master,
                    Hibernate.STRING
            );

            // Commit
            tx.commit();


<hibernate-mapping>

    <class name="com.mycompanypackage.AccountProfile" table="ACCOUNT_PROFILE">

        <id name="id" type="integer" column="AP_ID" unsaved-value="0">
                <generator class="identity"/>
        </id>

        <property name="master" type="string">
            <column name="MASTER" not-null="true"/>
        </property>
    </class>

</hibernate-mapping>



The "master" property is an java.lang.String that has been populated by a Webwork action. This works just fine from Hibern8IDE but I get a classcastexception on the session.find row when running from my action!

I've run out of ideas...

/Jonas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 6:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Show the exception stack trace.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 7:22 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Session.find returns a java.util.List


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 7:22 am 
Beginner
Beginner

Joined: Fri Jan 02, 2004 7:07 pm
Posts: 35
The offending rownumber is the session.find() row above...

If I load() a specific instance on a hardcoded id it seems to work just fine.

/Jonas


2004-01-22 11:44:56,231 INFO [com.mycompanypackage.actions.ClientProfile] - <Obtained a Hibernate session>
2004-01-22 11:44:56,481 ERROR [webwork.dispatcher.ServletDispatcher] - <Could not execute action>
java.lang.ClassCastException
at com.mycomapnypackage.actions.ClientProfile.doGet(ClientProfile.java:660)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at webwork.action.ActionSupport.invokeCommand(ActionSupport.java:415)
at webwork.action.ActionSupport.execute(ActionSupport.java:144)
at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:131)
at webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:174)
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:
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:
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:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:
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:
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:193)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:54
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
at java.lang.Thread.run(Thread.java:536)
2004-01-22 11:44:56,512 WARN [net.sf.hibernate.impl.SessionImpl] - <afterTransactionCompletion() was never called>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 7:51 am 
Beginner
Beginner

Joined: Fri Jan 02, 2004 7:07 pm
Posts: 35
drj wrote:
Session.find returns a java.util.List


OK. I'm blushing :)

My excuse is that I have been working around the clock the last three weeks to get up to speed on JSP, Beans, Tomcat, JNDI, WebWork, Hibernate, HsqlDB and last but not least ANT to get my first Java Webapp up and running for a major project here at work.

I haven't even looked at anything of the above before I started this project. I have used ANT before (but not actually built scripts myself) and I have been coding Java for about a year in professional capacity. But that's pretty much it.


OK. So I have done webapps in MySQL, Perl and PhP as a consultant before but that does not exactly count in this context...

I am going to keep posting stupid questions I am afraid. That's what sleep depravation and ignorance does for you :)

/Jonas

BTW I'm on my 24th consecutive working day (and night) in a row. What's your personal record ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 7:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
drj wrote:
Session.find returns a java.util.List


Hmpf, I should have seen that ...

Quote:
BTW I'm on my 24th consecutive working day (and night) in a row. What's your personal record ;)


Better get some sleep fast


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