@ManyToMany - Use Created Join Table in Another Class

Help
Sean
2013-09-07
2013-09-24
  • Sean
    Sean
    2013-09-07

    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?

    Thanks,
    Sean

     
  • Sean
    Sean
    2013-09-18

    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.
    http://stackoverflow.com/questions/18859031/use-join-table-in-separate-entity

     
  • Javier Paniza
    Javier Paniza
    2013-09-20

    Hi Sean,

    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.

     
  • Sean
    Sean
    2013-09-21

    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?

     
  • Javier Paniza
    Javier Paniza
    2013-09-24

    Hi Sean,

    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.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
    Last edit: Javier Paniza 2013-09-24