• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mapping legacy data, no fkey

 
Franck McGeough
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table in a legacy system which has subscription information in it. The subscription is either user based or group based. There is a field in the subscription tables that is set to 0 if its user and 1 if its group. There is a single column that either joins with the user table or with the group table and then to the User table. (I understand this isn't what you'd do if you were designing this thing from scratch but that's what I've got to deal with).

This whole thing is the primary key of the subscription table. That is, itemid, userid, isgroup.

I didn't map the User object or the Group object to this Subscription in the mapping files because I have no idea how to express this or whether or not it should be expressed.

How do I join the Group to the Subscription without it being explicitly mapped? That is, I want to express :

Subscription.userid = Group.groupid and Group.users.uid = :myid

The Hibernate parser doesn't like when it hits anything referring to Group (I assume because it doesn't find any such relationship in the mapping document).

Are there any examples of solving this sort of wacky setup in Hibernate that someone could point me to?
 
Franck McGeough
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I figured out what I was doing wrong. Hibernate didn't like me using "as group" for the Group table alias.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic