java - How to use join tables with hibernate -
i having difficulty using hibernate select using join tables represent many many.
i have following 3 tables (bold represents links / keys)
user {id, username, password}
group {id, name, scpid}
join table = member {id, groupid, username}
so have scenario in dao user , group want available groups , available members respectively.
this means need provide mapping unsure how this. far groups user have tried complains duplicate username
@manytomany(fetch = fetchtype.lazy, cascade = cascadetype.all) @jointable(name = "member", joincolumns = {@joincolumn(name = "username", nullable = false, updatable = false)}, inversejoincolumns = {@joincolumn(name = "username", nullable = false, updatable = false)}) public set<group> getgroups() { return usergroups; } public void setgroups(set<group> usergroups) { this.usergroups = usergroups; }
can me in identifying how solve please?
thanks
according provided code snippet both @joincolumn
's name
attribute having username
value.
Comments
Post a Comment