-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to map a Map in hibernate with @OneToMany relation ?
PostPosted: Mon Oct 24, 2011 1:11 pm 
Newbie

Joined: Mon Oct 17, 2011 1:50 pm
Posts: 5
i have a table

**Permission**:

- permission_id
- permission_name
- permission_desc

and a table **PermissionCategory** with one to many relation to **Permission**



is it possible to return map <key,value> in one to many relationship instead of list.
this is what i am doing right now in **PermissionCategory** domain:

Code:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
       @JoinTable(name = "perm_cat_map", joinColumns = { @JoinColumn(name = "perm_cat_id") }, inverseJoinColumns = { @JoinColumn(name = "permission_id") })
       private List<Permission> permissions = new ArrayList<Permission>(0);


is it possible to have something like:

Code:
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
           @JoinTable(name = "perm_cat_map", joinColumns = { @JoinColumn(name = "perm_cat_id") }, inverseJoinColumns = { @JoinColumn(name = "permission_id") })
           private Map<String,String> permissions = new ArrayList<String,String>(0);


where the two strings are **permission_id**, **permission_name**.

please advise, thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.