Hey guys,
We have a scenario where our manytomany table is not simply two foreign id's. basically we have an entity that has (many) relationships to itself.
ie an ITEM object may have many associated ITEM, defined by relationship_type
so (* is PK, ^ is FK)
ITEM(id*, name ...)
ITEM_RELATIONSHIP(fromItemID*^, toItemID*^, relationship_type*)
so for any item, we can have many related items, and each related item has a relationship_type(ie. child, sibling etc)
So the following will return all items related, and i want to return only those with relationship_type = 'CHILD'
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(name = "item_relationship", inverseJoinColumns = {@JoinColumn(name = "toItemId")}, joinColumns = {@JoinColumn(name = "fromItemId")}) getChildRelationships()