This discussion is archived
0 Replies Latest reply: Jul 26, 2011 7:33 AM by 199225 RSS

JPA Secondary Table vs Relationship

199225 Newbie
Currently Being Moderated
I am trying to persist class cant modify it, as it was done by an external agency, and we cant change the code.

class BaseModel{
Long uid;

     * The change history.
     private List<String> changeLog;
     * The date last modified and persisted.
     private Date modificationDate;

     * The date created.
     private Date creationDate;

class Article extends BaseModel{

//other properties
* Language code as returned by
* Locale locale = new Locale("language code");
* locale.toString()
String locale;
*Text in that particular languae
String text;


     <mapped-superclass class="BaseModel">
               <id name="uid">
                    <column name="UID" nullable="false" />
                    <generated-value strategy="AUTO" />

               <basic name="creationDate">
                    <column name="CREATIONDATE" updatable="false" nullable="false" />
               <basic name="modificationDate">
                    <column name="MODIFICATIONDATE" updatable="true" nullable="false" />

               <element-collection name="changeLog">

     <entity class="Article"
          name="Article " metadata-complete="true">
          <table name="Article " />
          <inheritance strategy="JOINED" />
          <secondary-table name="ArticleML">
               <primary-key-join-column name="UID"
                    referenced-column-name="UID" />
               <basic name="locale">
                    <column name="LOCALE" updatable="false" nullable="false" table="ArticleML"/>
               <basic name="text">
                    <column name="TEXT" updatable="false" nullable="false" table="ArticleML"/>

Its creating secondary table and populating it with data, what i wanna do is;
In secondary table create composite key made of ArticleID + AutoGenerate Primary Key for the table + locale
And when retrieving it should retrieve based on locale.
Its a relation in how its broken down, but from OO/JPA prespective its not, its a multilingual field.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points