1 Reply Latest reply on Mar 4, 2008 8:03 AM by christian.bauer

    Mapping database lookups to jpa entities

    yaaji

      I have the following database tables: lookup and employee.


      Lookup Table: structure with sample data.








      class_namevaluedescription
      SEX_CODE1Male
      SEX_CODE2Female
      BANK_CODE1HSBC
      BANK_CODE2CityBank


      Employee Table: structure with sample data.








      idnamesex_codebank_code
      1Yusuf11
      2Maher12
      3Suzan21




      What is the best way to map them into jpa entities?

      I tried to map an abstract class to lookup table and use class_name column as discriminator for the subclasses Sex and Bank and reference the bank and sex as ManyToOne in the employee object.. but I'm getting a class cast exception when the sex_code and bank_code has the same value.


      I tried to create views Sex_lookup and Bank_lookup and map them directly to entities. again hibernate complains that he can't find a table with such name.


      Help please.