-->
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: Multilingual Entities
PostPosted: Wed Nov 24, 2010 1:23 pm 
Beginner
Beginner

Joined: Fri Nov 13, 2009 4:05 pm
Posts: 30
We have a requirement that our domain entities must support multiple language descriptions. We have developed a base table structure for all products that insures each product gets a unique key, then based on this key and a language id, the descriptions of the products are stored in a separate table called product_descriptions.

Therefore given a single product ABC, I have the following in my description table:
Code:
KEY LANGUAGE LINE_NO DESCRIPTION
--- -------- ------- ----------------------------------------------------
ABC enUS     1       This is the english description of this product.
ABC enUS     2       This happens to be line 2 of the english description.
ABC esMX     1       Spanish translation here


The business' desire is that if I login with the Spanish locale, I should be shown the description in Spanish. Had I logged into the application with English, I would have been shown the two line English description. If the user had logged in using a French locale, the application wouldn't find a French translation, and should default to English instead. The caveat here is that its per-product based. Some products may have a French translation which should be shown while others may not, falling back to the English counterpart.

In the areas where I want to display the product description, I handle this by simply getting all description records from the product's getDescriptions() method and then iterate over all the results, skipping those that do not match the locale of the users session. The issue arises with this approach on large data sets where multiple calls are made back to the database for a specific records product description, which makes it highly inefficient.

Are there any constructs or methods by which I could have Hibernate do this for me when it populates the domain entity? Again I must stress, if the locale equivalent description doesn't exist, I would want the english substituted instead.

Thoughts on how I could do this aside from how I am doing it today?


Top
 Profile  
 
 Post subject: Re: Multilingual Entities
PostPosted: Thu Nov 25, 2010 5:31 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
crancran wrote:
In the areas where I want to display the product description, I handle this by simply getting all description records from the product's getDescriptions() method and then iterate over all the results, skipping those that do not match the locale of the users session. The issue arises with this approach on large data sets where multiple calls are made back to the database for a specific records product description, which makes it highly inefficient.

Are there any constructs or methods by which I could have Hibernate do this for me when it populates the domain entity? Again I must stress, if the locale equivalent description doesn't exist, I would want the english substituted instead.


You could those that match to users locale AND the english version. "where (language='enUs' or language=?)" So you don't need a second call.


Top
 Profile  
 
 Post subject: Re: Multilingual Entities
PostPosted: Fri Feb 18, 2011 11:55 am 
Newbie

Joined: Wed Mar 10, 2010 12:03 pm
Posts: 7
any solution available for this problem ?

regards

Armando


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.