aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate mapping List<Integer> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate mapping List<Integer>" Watch "Hibernate mapping List<Integer>" New topic
Author

Hibernate mapping List<Integer>

Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
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
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1760
    
    7

You could use JPA's ElementCollection annotation for that purpose. There's an example in the API documentation I linked to.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
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

Joined: Mar 10, 2008
Posts: 1760
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate mapping List<Integer>