|
Re: JoinTable with additional column [message #932964 is a reply to message #932490] |
Thu, 04 October 2012 12:05  |
Eclipse User |
|
|
|
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:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/MappingSelectionCriteria
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.
|
|
|
Powered by
FUDForum. Page generated in 0.05364 seconds