Hey everyone,
I've spent a few hours pondering how to approach this mapping in Hibernate, it's very possible there's an easy solution that I'm missing but I'm stumped currently, and would really appreciate any insight.
Essentially, what I'm trying to do is keep a recording of the time a join occured between two objects, here's an example.
A USER instance can subscribe to many THREAD instances, and vice versa, thus a many-to-many relationship. In addition, I wish to record the time that the subscription was made, so I can keep track of the most recent subscriptions of the user. In a database, typically this would be mapped as follows:
USER [user_id] THREAD [thread_id] USER_THREAD [user_id, thread_id, subscription_time]
I'm trying to figure out how to model this on the Java side. Typically, I would create a USER object that returns a list of THREAD objects, but have no idea how I'd track the subscription time value without an additional wrapper class to handle the relationship (which I'd really like to avoid). I know lists can have an order value, but I would prefer to record the time instead of the order per say, as it's a more accurate data model and would make it easier for some of our management-based tasks.
Thanks so much for any help! Shawn
|