Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JoinTable with additional column
JoinTable with additional column [message #932490] Thu, 04 October 2012 06:32 Go to next message
Pavel Zelenka is currently offline Pavel ZelenkaFriend
Messages: 61
Registered: July 2009

I would appreciate a little help with OneToMany relation using JoinTable. I use EclipseLink 1.1.4

Let's say there are entities Person and Projects. There is a join table which connects projects to persons. But the join table has an additional column "is_valid". Is there any way to tell the EclipseLink to relate only those entities where is_valid=1?
Or the best way is to use entity class for the join table (



Re: JoinTable with additional column [message #932964 is a reply to message #932490] Thu, 04 October 2012 16:05 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1300
Registered: July 2009
Senior Member
While I'm usually against it because it hides data from your object model, there is a way to filter results for the mapping described here:

This allows you to add in the is_valid=1 to the queries bringing in the data for the mapping. It means though that your cache will not always represent what is in the database - changing is_valid may require the owning entity to be refreshed to have the changes reflected in the entity.

Unless the mapping is read-only though, you will need to map it somehow so it can be inserted into when entities are added to the collection. I usually recommend the Mapping_a_Join_Table_with_Additional_Columns approach because it reflects what is in the database, and allows the application to decide what to display. The entity can transparently filter results to the app with say a getValidEntities method, and allows for queries using the is_valid field if required in the future.
Previous Topic:JTA
Next Topic:Hibernate migration
Goto Forum:

Current Time: Mon Jun 25 10:28:55 GMT 2018

Powered by FUDForum. Page generated in 0.01523 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top