tags:

views:

21

answers:

0

Hibernate Gurus,

I have a pesky issue and I don't really know how to solve my problem. I have a solution, however, I feel I may be reinventing the wheel.

I have two entities, The first is a User Object, The second is an Alias Object. The relationship between the two is that A USER can have multiple ALIAS(es) and an ALIAS can be tied to at most one user.

I would like to be able to grab an Alias object out of the Alias table and Eagerly grab the corresponding User, as well. (This part is working perfectly). I also want hibernate to populate the complete list of ALIAS(es) which a User has (this also is working perfectly), however, I also want to know which of the ALIASes was used to query for the USER object.

The first two I was able to solve quite easily with a bi-directional ManyToOne, OneToMany relationship, the third, however, seems to be not so easy. I guess I could just as easily create a @Transient field in User and set that in my Dao, however, I just want to know if there is a way I could have Hibernate do it for me.

I can post just about any code necessary to help facilitate answering.

Thanks.