users@glassfish.java.net

Extra columns in join table?

From: <glassfish_at_javadesktop.org>
Date: Tue, 24 Jul 2007 01:34:09 PDT

I have a services table and a person table. A person can have access to many services, and a service can be accessed by many persons. To map this relationship, I plan on using a join table (as I've done with several other M-M relationships in the same application).

But what's different here is that there are two access levels. I could solve this by adding a column to the join table called "accesslevel", and this level could be looked up using ordinary SQL.

Since I'm using JPA, this join happens behind the scenes, and I'm able to get a list of persons having access to a service, or get a list of services a person has access to using "getServices()" and "getPersons()" methods in the respective entity classes.

So how can I access this extra column in the join table? Do I need to manually create an additional query to the database?

Or is there another completely different way this should be solved?

Thanks
Marius Waldal
[Message sent by forum member 'mariusw' (mariusw)]

http://forums.java.net/jive/thread.jspa?messageID=227894