Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:50:24+00:00 2026-06-18T09:50:24+00:00

After much debate on choosing an approach for an internationalized database design I went

  • 0

After much debate on choosing an approach for an internationalized database design I went with having two tables for each table that requires translation. I’m having some trouble with ORM in the following case.

So I have the following tables:

cat          cat_t               subcat            subcat_t 
------       -------             ----------        ------------
id (pk)      cat_id(pk,fk)       id(pk)             subcat_id(pk,fk)
             locale(pk)          cat_id(fk)         locale(pk)
             name                                   name
@Entity 
@Table(name = "cat")
@SecondaryTable(name = "cat_t",
    pkJoinColumns = @PrimaryKeyJoinColumn(name = "cat_id", 
                                          referencedColumnName = "id"))
@IdClass(TranslationKey.class)
public class Category {
    @Id 
    private long id;

    @Id
    @Column(table = "cat_t")
    private String locale;

    @Column(table = "cat_t")
    private String name;

    @OneToMany(fetch = FetchType.LAZY)
    private List<SubCategory> subCategories;

    // getters and setters
 }
@Entity
@Table(name = "subcat")
@SecondaryTable(name = "subcat_t",
    pkJoinColumns = @PrimaryKeyJoinColumn(name = "subcat_id", 
                                          referencedColumnName = "id"))
@IdClass(TranslationKey.class)
public class SubCategory{

    @Id
    private long id;

    @Id
    @Column(table = "subcat_t")
    private String locale;

    @Column(table = "subcat_t")
    private String name;

    @Column(name = "cat_id")
    private long categoryId;

    // getters and setters
}
public class TranslationKey implements Serializable {

    private long id;
    private String locale;

    // getters and setters
}

My goal is for subcategories to only pull back the subcategories for the locale of the parent. I think I have some options including, querying the subcategories separately and making the field transient or pull everything back (all subategories for all languages) and then just filter out the ones I want.

The issue I have had with @JoinColumn is that locale is part of the secondary table for both cat can subcat and so when I try the referencedColumn that may not be allowed since its not in the same table?. I’m using EclipseLink but I’m not really tied to a JPA Provider.

Any help/guidance is much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:50:26+00:00Added an answer on June 18, 2026 at 9:50 am

    cat seems to have a one to many relationship with cat_t, since there can be many rows in cat_t for a single cat entry. This is not ideal to have in a single Entity, since it means you will have instances sharing data, and endless headaches if you make changes.

    A better approach that makes updates possible is to map the cat and cat_t to separate Entities, where Cat has a collection of Cat_t?Local instances. The entity mapping to cat_t can use the local and its ManyToOne back pointer to Cat as its Id:

    @Entity
    @IdClass(TranslationKey.class)
    public class Local {
      @ID
      private String locale;
      @ID
      @ManyToOne
      private Cat cat;
    }
    
    public class TranslationKey{
      string local;
      long cat;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After much reading on ruby on rails and multiple database connections, it seems that
I'm having a bug in my code that's kicking my ass, so after much
So after much debate back and forth, I've come up with what I think
After much reading it seems that, really, the only way to read a number
Currently trying at add ajax to a site, after much reading I discovered that
So I've decided after much debate and research to use symfony on my next
After much searching and looking extensively, I have a question that is undoubtedly dumb
After much searching, I have not found a satisfactory method that is easy to
After much searching and trials, I am stuck... I have two classes, one is
It appears after much searching that there seems to be a common problem when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.