-->
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: Automatic join mapping of a single column
PostPosted: Sun Aug 12, 2007 1:38 pm 
Newbie

Joined: Sun May 27, 2007 7:44 am
Posts: 5
Hello!

I'm currently experiencing some performance related issues with my Hibernate webapp.

Background:

I have several entities in the database that needs to be translated upon request depending on which "store" the user is in. My currect, really stupid, solution works almost like this:
Code:
class Item {

   List<Store> stores; //ManyToMany Mapped relationship to the Store table

   private transient String translation;

   public String getTranslation() {
      return translation;
   }

   public void setTranslation( translation ) {
      this.translation = translation;
   }
   
}

class ItemTranslation {

   Store store; //Mapped relationship
   Item item; //mapped
   
   private String translation;
}


Then when I load all items from the database, iterate over them and set the translated transient value:
Code:
Store store; //Is kept by the usersession (set depending on which URL the user visits)

List<Item> items = ... //Load using critieria
for( Item itm : items ) {
   String translation = ... //Find the translation that matches "itm" and "store"
   itm.setTranslation( translation );
}


This of course generated alot of overhead queries and made the site crawl when loading.

Surely there must be some way of getting Hibernate to automatically join Item with ItemTranslation in one query when I load all items? How would I supply my "Store" variable to that automatic query? I suppose I can't just create a special HQL-query to do the job because I load Items (and serveral other, more complex entities) through different Hibernate criterias and therefore need a more "transparent" solution.

Sincerely,
John

Hibernate version:
Hibernate 3.2.3.ga with Annotations

Name and version of the database you are using:
MySQL 5.0


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.