-->
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.  [ 3 posts ] 
Author Message
 Post subject: Advanced o/r mapping need help!
PostPosted: Thu Oct 06, 2005 10:19 pm 
Newbie

Joined: Sat Aug 20, 2005 5:14 am
Posts: 9
Hi, my scenerio is:

table product
(
product_id int,
name varchar(20)
)

table product_description
(
product_id int,
lang_id smallint,
description
)

I want to have a class FullProduct which have a "composite-id" of product_id and lang_id. The class will look like this...

public class FullProduct
{
class PK() {...} // inner class
PK pk;
String name,
String description
}

I can do this easily with a table VIEW. Which, is NOT able to update!!
Any suggestion how can i do it? I am afriad <joined-subclass> cannot help ...

I totally understood that this is NOT a common situation, but this design will save many development days...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 6:21 pm 
Newbie

Joined: Wed Mar 30, 2005 8:58 am
Posts: 10
Location: São Paulo / Brazil
Why don't you add a column called product_desc_id and, to protect your data from hard inserts and updates, create an index based on those two columns (product_id, lang_id) and make this index unique?

This give you the same idea from having composite-id. But gives you more: the simplicity of a simple, incremental, primary and beautiful key.

_________________
www.brunoborges.com.br


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 09, 2005 5:27 am 
Newbie

Joined: Sat Aug 20, 2005 5:14 am
Posts: 9
Thx for you suggestion.

Do you mean making the product_descr like this?

table product_description
(
product_desc_id int, --PK
product_id int, -- IX
lang_id smallint, -- IX
description varchar(),
)

But how can this solve my problem?

A FullProduct means a product with full detail in the specific language version....

i.e. in my old system, the code work like:

FullProduct p = ProductDAO.find(productID, langID);
System.out.println("ProductID: " + p.getProductID());
System.out.println("Description: " + p.getDescription());


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.