-->
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.  [ 1 post ] 
Author Message
 Post subject: Proper-ref mapping different data types
PostPosted: Fri Mar 13, 2009 1:24 pm 
Newbie

Joined: Fri Mar 13, 2009 10:36 am
Posts: 10
Hi

I am using Hibernate version: 3.0.

I am trying to map the Id of class Phone to PropertyRef text field. As this text field is used for other reasons as well.

class Phone
{
int id;
PropertyRef propRef;

//getter and setters
}

class PropertyRef
{
int propId;
String text;
}

<class name="com.test.hibernate.sub.Phone" table="Phone" dynamic-insert="true"
dynamic-update="true" select-before-update="false">

<id name="id" column="id">
<generator class="assigned" />
</id>
<one-to-one name="propRef" class="com.test.hibernate.sub.PropertyRef" cascade="all" fetch="select" property-ref="text"/>
</class>


This works fine when I insert into the database. But when I try and retrive the Phone object it throws a ClassCastException : java.lang.Integer.

Is there anyway I can get around it ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.