-->
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: one-to-one help
PostPosted: Thu Feb 12, 2004 5:21 am 
Newbie

Joined: Thu Feb 12, 2004 4:33 am
Posts: 7
I am new to hibernate and trying my hand on it. This may sound a very basic query but i could not get it reading the docs.

I have two tables:

ARTICLE: which has certain number of fields with
articleCode as the primary key and other information like
description, life time, etc
It also has a brandCode which is a primary key of another table called
BRAND which stores information about brand like description, etc

In my Article object which is mapped to the Article table, i have one more property called brand description which i have to pick from the brand table depending on the brandCode that i have in the Article object. It is a straighforwar one-to one mapping between Article and Brand.

I need only a text field from the brand table (description) in the Article object. What mapping should i use and how do I retrieve the data most efficiently.

Thanking in anticipation,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 7:03 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You cannot (yet) map an object into several tables.

So map article -> brand in a many-to-one way and add a unmapped getter on the description

Code:
public String getBrandDescription() {
  return getBrand().getDescription();
}

_________________
Emmanuel


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.