-->
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: how to retrieve object using a non-id attribute?
PostPosted: Tue Nov 02, 2004 12:25 am 
Newbie

Joined: Wed Oct 27, 2004 6:05 am
Posts: 6
I have the following table:

create table "product"
(
"uid" int8 not null,
"name" text not null unique,
"description" text
)

The uid is the id in the mapping file. But I'd like to be able to retrieve a row based on the name. Doing
Code:
Product prod = (Product) session.get(Product.class, name);

does not work, as the id is defined as Long, and hibernate is trying to cast it to a Long.

Here's my mapping:
Code:
   <class name="com.mydomain.hb.Product" table="PRODUCT">
      <id name="id" column="uid" type="long">
         <generator class="increment"/>
      </id>
      <property name="name" column="name" update="false" not-null="true" unique="true"/>
      <property name="description" column="description"/>
      
   </class>


How can I retrieve a row using a name, just like I do with the id?

thnx


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 1:34 am 
Newbie

Joined: Wed Oct 27, 2004 6:05 am
Posts: 6
Never mind, got it to work.


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.