Hi all!
I am a new hibernate user, and i am trying to get inside of the hibernate complex world.
Currently i need to do the following. I have 3 tables defined: player, team and player_team_assoc.
The third table (player_team_assoc) was defined to satisfy the needing of have a many-to-many relationship between team and player tables.
Basically the tables structure is like this:
Player Team player_team_assoc
------- ------- -----------------------
(PK)player_id (PK)team_id (PK)team_id
player_name team_name (PK)player_id
is_team_manager
My problem arrives when i try to set the 'is_team_manager' field of the 'player_team_assoc' table to a Player java object in the player hiberante definition.
I have tried everything, i tried to put a composite-element, element, keys, etc, but i cannot find the way to say that i want to load the 'is_team_manager' field to a player object.
In the next lines i attach the bag xml definition of Player and Team elements:
Player definition
-------------------
<bag name="collectionTeams" table="player_team_assoc" inverse="true" cascade="all" lazy="true">
<key column="player_id" />
<many-to-many column="team_id" class="slm.persistence.dao.team.Team" />
</bag>
Team definition
------------------
<bag name="collectionPlayers" table="player_team_assoc" cascade="all" lazy="true">
<key column="team_id" />
<many-to-many column="player_id" class="slm.persistence.dao.player.Player" />
</bag>
The hibernate version iam using is 3.1 and the database is MySql-4.0.16
Since now, THX for any help!! :)
|