the-gtm wrote:
What you can do is use a bag of composite elements in your team object :
Code:
<bag name="collectionPlayers" table="player_team_assoc" cascade="all" lazy="true">
<key column="team_id" />
<composite-element class="TeamMember">
<many-to-many column="player_id" class="slm.persistence.dao.player.Player" />
<property name="isTeamManager"/>
</composite-element>
</bag>
Where TeamMember is a class that has a Player and a isTeamManager attributes.
An other (better ?) way to to this would be to add a teamManager attribute to your Team object (If a team has exactly one manager)
I tried the solution of put that code on the Player xml definition, and add an attribute called 'isTeamManager' to it, but when i try to execute a simple query to load a player it throws me this exception:
Code:
Caused by: org.xml.sax.SAXParseException:
The "composite-element" dont allow "many-to-many" in this place.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3317)
And the Player definition looks like this now:
Code:
<bag name="collectionTeams" table="player_team_assoc" inverse="true" cascade="all" lazy="true">
<key column="player_id" />
<composite-element class="slm.persistence.dao.player.Player">
<many-to-many column="team_id" class="slm.persistence.dao.team.Team" />
<property name="is_team_manager"/>
</composite-element>
</bag>
I guess that bag doesnt allow that order or something like that... i change that declaration through all the bag tag :) but it didnt work.
MORE HELPPPPPPPPP d:
Bytes!
Pablo