-->
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: problem with set mapping
PostPosted: Thu May 28, 2009 10:26 am 
Newbie

Joined: Wed May 27, 2009 7:43 pm
Posts: 4
Hello all,

I'm having this problem for the past couple of days:

I have a USERS table and a REVIEWS table, where the connection between them is one-to-many (a user has many reviews), based on the column USER_ID, found in both tables (long). However, the USER_ID column is NOT the primary key for the REVIEWS table: I have a REVIEW_ID (string) as a primary key, and the USER_ID is a foreign key.

The problem is that when i get a User object from the db (MySQL), i get an error:
Code:
java.sql.SQLException: Invalid value for getLong() - '29ab8052-425f-417f-844a-635b1ef1a6a6'


whats the way around this??? I am attaching the two mapping files:
users.hbm.xml
Code:
<hibernate-mapping>
   <class name="com.domain.user.User" table="USERS">
      <id name="id" type="long" column="USER_ID">
         <generator class="native" />
      </id>
      <property name="name">
         <column name="USER_NAME" />
      </property>         
      <set name="reviews" lazy="false" inverse="true" cascade="save-update">
             <key column="USER_ID" not-null="true"/>
             <one-to-many class="com.domain.review.Review"/>
      </set>
          
      <property name="email">
         <column name="EMAIL" />
      </property>      
   </class>
</hibernate-mapping>


reviews.hbm.xml
Code:
<hibernate-mapping>
   <class name="com.domain.review.Review" table="REVIEWS">
      <id name="reviewId" type="string" column="REVIEW_ID">
         <generator class="assigned"/>
      </id>
      <many-to-one name="user" column="USER_ID" lazy="false" cascade="all" class="com.domain.user.User" not-null="true"/>
      <many-to-one name="reviewed" column="REVIEWED_ID" lazy="false" cascade="all" class="com.domain.reviewed.Reviewed" not-null="true"/>
      <property name="reviewText">
         <column name="REVIEW_TEXT" />
      </property>      
   </class>
</hibernate-mapping>


Thanks for the help, I truly appreciate 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.