Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Hibernate mapping List<Integer>

 
Ranch Hand
Posts: 138
2
  • Mark post as helpful
  • send pies
  • 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
  • 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: 138
2
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic