-->
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 with load
PostPosted: Tue Nov 25, 2003 9:01 am 
Newbie

Joined: Wed Oct 29, 2003 6:15 am
Posts: 7
Hi,

I have a problem with the method session.load(class, id), I have a ClassCastException
when I call a method


see the Exception :
java.lang.ClassCastException: java.lang.String
at genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization$$EnhancedByCGLIB$$0.getHybridization_id(<generated>)
at genoplante.TestTranscriptomeConfiguration.main(TestTranscriptomeConfiguration.java:52)

see my code :

URLconfigFile=TestTranscriptomeConfiguration.class.getResource("/resources/transcriptome/transcriptome.cfg.xml");
Configuration cfg = (new Configuration()).configure(configFile);
SessionFactory sessions = cfg.buildSessionFactory();
Session s = sessions.openSession();
Hybridizationh=(Hybridization)s.load(genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization.class, "2");

System.out.println(h.getHybridization_id().toString());
s.close();



see my mapping file :

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization"
table="HYBRIDIZATION"
proxy="genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization"
dynamic-update="false"
dynamic-insert="false"
>

<jcs-cache usage="read-only" />

<id
name="hybridization_id"
column="HYBRIDIZATION_ID"
type="java.lang.Integer"
>
<generator class="sequence">
</generator>
</id>

<property
name="order_nr"
type="java.lang.Integer"
update="true"
insert="true"
>
<column
name="ORDER_NR"
sql-type="INTEGER(9)"
/>
</property>

<property
name="is_replicated"
type="java.lang.Boolean"
update="true"
insert="true"
>
<column
name="IS_REPLICATED"
sql-type="BIT"
/>
</property>

<property
name="hybridization_date"
type="java.util.Date"
update="true"
insert="true"
>
<column
name="HYBRIDIZATION_DATE"
sql-type="DATETIME"
/>
</property>

<property
name="description"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="DESCRIPTION"
sql-type="VARCHAR(255)"
/>
</property>

<set
name="labeled_extract"
table="HYBR_LABELED_EXTRACT"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<jcs-cache
usage="read-only"
/>

<key
column="HYBRIDIZATION_ID"
/>

<many-to-many
class="genoplante.cargo.db.transcriptome.orm.hibernate.Labeled_Extract"
column="LABELED_EXTRACT_ID"
outer-join="auto"
/>

</set>

<set
name="experiment_t"
table="EXP_HYBR"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<jcs-cache
usage="read-only"
/>

<key
column="HYBRIDIZATION_ID"
/>

<many-to-many
class="genoplante.cargo.db.transcriptome.orm.hibernate.Experiment"
column="EXPERIMENT_ID"
outer-join="auto"
/>

</set>

<set
name="image_scanning"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<jcs-cache
usage="read-only"
/>

<key
column="HYBRIDIZATION_ID"
/>

<one-to-many
class="genoplante.cargo.db.transcriptome.orm.hibernate.Image_Scanning"
/>
</set>

<property
name="operator_id"
type="java.lang.Integer"
update="true"
insert="true"
>
<column
name="OPERATOR_ID"
sql-type="INTEGER(9)"
/>
</property>

<many-to-one
name="operator"
class="genoplante.cargo.db.transcriptome.orm.hibernate.Operator"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="OPERATOR_ID"
/>
</many-to-one>

<property
name="array_id"
type="java.lang.Integer"
update="true"
insert="true"
>
<column
name="ARRAY_ID"
sql-type="INTEGER(9)"
/>
</property>

<many-to-one
name="array"
class="genoplante.cargo.db.transcriptome.orm.hibernate.Array"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="ARRAY_ID"
/>
</many-to-one>

<property
name="hybridization_link_id"
type="java.lang.Integer"
update="true"
insert="true"
>
<column
name="HYBRIDIZATION_LINK_ID"
sql-type="INTEGER(9)"
/>
</property>

<many-to-one
name="hybridization_link"
class="genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="HYBRIDIZATION_LINK_ID"
/>
</many-to-one>

<set
name="hybridization"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<jcs-cache
usage="read-only"
/>

<key
column="HYBRIDIZATION_LINK_ID"
/>

<one-to-many
class="genoplante.cargo.db.transcriptome.orm.hibernate.Hybridization"
/>
</set>

<property
name="protocol_id"
type="java.lang.Integer"
update="true"
insert="true"
>
<column
name="PROTOCOL_ID"
sql-type="INTEGER(9)"
/>
</property>

<many-to-one
name="protocol"
class="genoplante.cargo.db.transcriptome.orm.hibernate.Protocol"
cascade="none"
outer-join="auto"
update="false"
insert="false"
>
<column
name="PROTOCOL_ID"
/>
</many-to-one>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Hybridization.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


But when I use the method session.find("from Hybridization.class c where c.id=2");
I don't have any exception.


Do you have any idea.
Thank for your help

Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 9:05 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
In your mapping, you declare your ID as an Integer.
When you call session.load(), you pass it a String.

Hence the ClassCastException...


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.