• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate mapping List<Integer>

 
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

Can somebody help with hibernate mapping file to map List<Integer>

Example :

Calss Game
int gameId;
String gameName;
List<Integer> playDays;

Tables:
GAME TABLE
GAMEID INT(4)
GAMENAME VARCHAR(10)
....
....
AND PRIMARY KEY IS GAMEID

GAME_DAYS TABLE
GAMEID(4)
PLAYDAY INT(1)

GAMEID,PLAYDAY Together primary key
GAMEID forighn KEY

I know how to map list<objects> like list<student> etc.. but not sure how to map list<String> or list<Integer> can somebody help me...

Thanks
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use JPA's ElementCollection annotation for that purpose. There's an example in the API documentation I linked to.
 
Bala Tilak
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I saw that one. I have been using xml configuration rather than annotations.

Can you we achieve similar mapping using xml configuration.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, with <element-collection> in orm.xml. There's an example in the EclipseLink (JPA 2 reference implementation) documentation here.
Oh, and if you're using Hibernate specific .hbm.xml files you can use the <element> mapping.
 
reply
    Bookmark Topic Watch Topic
  • New Topic