-->
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.  [ 5 posts ] 
Author Message
 Post subject: ClassCastException
PostPosted: Thu Aug 11, 2005 3:20 am 
Newbie

Joined: Mon Aug 01, 2005 3:07 am
Posts: 10
hello,
I have a table:
CREATE TABLE OPERMENU
(
PROJECTNAME VARCHAR2(20) NOT NULL,
SEQNO NUMBER(5) NOT NULL,
PARENTSEQNO NUMBER(5) NOT NULL,
GROUPSEQNO NUMBER(5),
LABEL VARCHAR2(50),
DESCRIPTION VARCHAR2(500),
ACTION VARCHAR2(500),
DISPLAYPROFILE VARCHAR2(500),
PROCESS_DATE DATE,
PROCESS_TERMINAL VARCHAR2(50),
PROCESS_USER VARCHAR2(15)
)
ALTER TABLE OPERMENU ADD (
CONSTRAINT PK_OPERMENU PRIMARY KEY (PROJECTNAME, SEQNO)

and mapping file.
hibernate-mapping schema="XYZ" package="entities" default-lazy="false">
<class name="Opermenu" lazy="false" table="OPERMENU" schema="PCPM">
<composite-id name="compositeId" class="entities.Opermenu$OpermenuCompositeId" unsaved-value="any">
<key-property name="projectname" type="string">
<column name="PROJECTNAME" length="20" not-null="true" index="PK_OPERMENU"/>
</key-property>
<key-property name="seqno" type="big_decimal">
<column name="SEQNO" not-null="true"/>
</key-property>
</composite-id>
<property name="parentseqno" type="big_decimal">
<column name="PARENTSEQNO" not-null="true"/>
</property>
<property name="groupseqno" type="big_decimal" column="GROUPSEQNO"/>
<property name="label" type="string">
<column name="LABEL" length="50"/>
</property>
<property name="description" type="string">
<column name="DESCRIPTION" length="500"/>
</property>
<property name="action" type="string">
<column name="ACTION" length="500"/>
</property>
<property name="displayprofile" type="string">
<column name="DISPLAYPROFILE" length="500"/>
</property>
<property name="processDate" type="date" column="PROCESS_DATE"/>
<property name="processTerminal" type="string">
<column name="PROCESS_TERMINAL" length="50"/>
</property>
<property name="processUser" type="string">
<column name="PROCESS_USER" length="15"/>
</property>
</class>
</hibernate-mapping>

When I execute:
Criteria crt = session.createCriteria(Opermenu.class);
java.util.List list = crt.list();

I get an error:
java.lang.ClassCastException
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:759)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:292)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at manager.OperManager.getOperMenus(OperManager.java:25)
at actions.operMenuAction.execute(operMenuAction.java:28)
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 weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

How can handle this error


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 4:10 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Do you classes implement Serializable ?
Can you post the code of your classes?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 4:12 am 
Newbie

Joined: Mon Aug 01, 2005 3:07 am
Posts: 10
no ..
is it necessary??


public class Opermenu{

//auto generated
private OpermenuCompositeId compositeId;
//auto generated
private BigDecimal parentseqno;
//auto generated
private BigDecimal groupseqno;
//auto generated
private String label;
//auto generated
private String description;
//auto generated
private String action;
//auto generated
private String displayprofile;
//auto generated
private Date processDate;
//auto generated
private String processTerminal;
//auto generated
private String processUser;


//auto generated
public void setCompositeId(OpermenuCompositeId value) {
this.compositeId = value;
}

//auto generated
public OpermenuCompositeId getCompositeId() {
return this.compositeId;
}

//auto generated
public void setParentseqno(BigDecimal value) {
this.parentseqno = value;
}

//auto generated
public BigDecimal getParentseqno() {
return this.parentseqno;
}

//auto generated
public void setGroupseqno(BigDecimal value) {
this.groupseqno = value;
}

//auto generated
public BigDecimal getGroupseqno() {
return this.groupseqno;
}

//auto generated
public void setLabel(String value) {
this.label = value;
}

//auto generated
public String getLabel() {
return this.label;
}

//auto generated
public void setDescription(String value) {
this.description = value;
}

//auto generated
public String getDescription() {
return this.description;
}

//auto generated
public void setAction(String value) {
this.action = value;
}

//auto generated
public String getAction() {
return this.action;
}

//auto generated
public void setDisplayprofile(String value) {
this.displayprofile = value;
}

//auto generated
public String getDisplayprofile() {
return this.displayprofile;
}

//auto generated
public void setProcessDate(Date value) {
this.processDate = value;
}

//auto generated
public Date getProcessDate() {
return this.processDate;
}

//auto generated
public void setProcessTerminal(String value) {
this.processTerminal = value;
}

//auto generated
public String getProcessTerminal() {
return this.processTerminal;
}

//auto generated
public void setProcessUser(String value) {
this.processUser = value;
}

//auto generated
public String getProcessUser() {
return this.processUser;
}
public static class OpermenuCompositeId{

//auto generated
private String projectname;
//auto generated
private BigDecimal seqno;

//auto generated
public void setProjectname(String value) {
this.projectname = value;
}

//auto generated
public String getProjectname() {
return this.projectname;
}

//auto generated
public void setSeqno(BigDecimal value) {
this.seqno = value;
}

//auto generated
public BigDecimal getSeqno() {
return this.seqno;
}
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 6:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, ids must be of type Serializable. So your Opermenu$OpermenuCompositeId inner class must implement Serializable.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 7:10 am 
Newbie

Joined: Mon Aug 01, 2005 3:07 am
Posts: 10
Thank very much..

It should have to implement serializable and have a default constructor..


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