-->
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: simple one to many translation ... or not
PostPosted: Fri Feb 18, 2011 9:59 am 
Newbie

Joined: Wed Mar 10, 2010 12:03 pm
Posts: 7
Hi ..

I have a question about a problem that I cannot solve.

My Bean class
Code:
class Bean {
    private String id =null;
    private Set translations = new HashSet();
   

    //constructor + getters + setters
}


My Translation class
Code:

class Translation {

   private String title  = "";
   private String description = "";
   private Language language = "";
   
   // constructor + getters + setters

}



in my Bean.hbm.xml I would like to have
Code:

<set name="translations">
    <key column="bean_id" not-null="true" cascade="all" />
    <one-to-many class="Translation" />
</set>



in my Translation.hbm.xml i would like to have
Code:
    <class name="Translation" table="bean_translation">
      <id column="id" length="36" name="id" type="string" />
                <many-to-one column="fk_language_id" name="language"   not-null="false"  /> <!-- references LANGUAGE POJO -->
      <property   column="title"         name="title"      type="string"/>
      <property   column="updated"      name="updated"      type="timestamp"/>
   </class>


now to the problem.
I want to create UNIQUE KEY for language and bean id in my translation table!!! I need it cause every bean can have only 1 translation in specific language (1 english tittle and description)
Another thing I'm trying to avoid is
Code:
Translation t  = new Translation().setBean(instanceOfBean); // NO WAY !!!!


so adding translation to a bean must be done like this
Code:
Bean b = new Bean().addTranslation(instanceOfTranslation); //adds translation to the set !!!


I've been strugling with this for far too long .. so any help would be appreciated !

Regards

Armando


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.