I have a @ManyToMany join between two entities and I use @JoinTable to define the join table name and joinColumns. This works fine. I would like to reference this join table in a related entity, but since the join table does not have its own entity class, I can't determine how to reference it in my code. I would like to use a List to return related records from the join table. Is this possible to do or am I not using ManyToMany correctly?
In trying to find a solution for this issue, I found a StackOverflow thread related to my issue. I posted a question with code in this thread. Any help is appreciated. http://stackoverflow.com/questions/7602386/mapping-value-in-junction-table-to-entity/18807175#18807175
Solution to issue found via the example in the Stack Overflow thread. See the following post for complete details. The issue was in my composite ID class: http://stackoverflow.com/questions/18807321/mapping-value-in-junction-table-hibernate-propertyaccessexception-could-not-s
The issue is actually not resolved yet. I am still unable to use the join table created via a ManyToMany relationship in a separate entity. I have a new question opened on Stack Overflow with a new sample.
I think that answer you get in StackOverflow is right. If you want to use in your application data from join table you cannot use a @ManyToMany, but you have to map the join table with an entity.
If you still have problems or you need help to display this collection nicely with OpenXava, don't doubt in asking again.
Help others in this forum as I help you.
Need more help? Get OpenXava professional support.
Thanks, Javier. I have used the StackOverflow solution and it works well. Referring to the StackOverflow example of EMP, PROJ and the EMP_PROJ join table, I have EMP_JOIN mapped to an entity and can reference it in new entity classes. What I am now trying to do is use EMP_PROJ in a new @ManyToMany join with a different entity, which will display a list of the projects mapped to a specific employee stored in the EMP_PROJ table. Using a @ManyToMany in the new entity works fine, but it does not allow me to filter the projects displayed to a specific employee. Instead, all records in EMP_PROJ are displayed.
Is it possible to add a @WHERE clause to a @ManyToMany so the records displayed in the List are restricted via the @WHERE clause?
the UI interface for @ManyToMany collections in OpenXava is the same as for calculated collection, that is without filtering, ordering and paging.
Try to use a calculated collection.
Another option is to define a @OneToMany relationship against your new entity that maps the join table, and use @CollectionView and @ListProperties to show the data of the other part of the relationship.