Hello all.
So, I am currently attempting to create a .hbm file for a link table, and running into some issues. First off, some details:
I have 1 table called
Ability and another table called
CastMember. These tables have a many-to-many relationship (cast members can have many abilities and vice versa), so I created a link table, called
Ability_CastMember. Here are the table details:
Code:
Ability
create table Ability
(
id int not null primary key,
name varchar(30),
description text,
abilityTypeID int not null references AbilityType(id)
)type=InnoDB;
CastMember
create table CastMember
(
id int not null primary key,
name varchar(30),
displayName varchar(30),
description text,
quote text
)type=InnoDB;
Ability_CastMember
create table Ability_CastMember
(
abilityID int not null,
castMemberID int not null,
primary key (abilityID, castMemberID),
foreign key (abilityID) references Ability (id),
foreign key (castMemberID) references CastMember (id)
)type=InnoDB;
Now, I currently have a mapping file for the
Ability table which allows me to get a Set containing all
CastMembers, and was going to do the inverse in my
CastMember mapping file. At any rate, here is
Ability.hbm.xml:
Code:
<hibernate-mapping>
<class name="com.brc.roe.db.ability.entity.Ability" table="Ability">
<id name="id" column="ID">
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name"/>
</property>
<property name="description" type="text">
<column name="description" />
</property>
<many-to-one name="abilityType" class="com.brc.roe.db.ability.entity.AbilityType" lazy="false">
<column name="abilityTypeID" />
</many-to-one>
<set name="castMembers" table="Ability_CastMember" cascade="all" lazy="false">
<key column="abilityID" />
<many-to-many column="castMemberID" class="com.brc.roe.db.cast.entity.CastMember"/>
</set>
</class>
</hibernate-mapping>
This of course works as expected. So at this point, I was thinking that I didn't even need to have a entity/mapping for the link table! Now here is the issue... All of the data for these tables is static, and thus I keep it in xml files. I use Castor to unmarshall the XML into the entities, and then use hibernate to persist them. So, turns out I need a
Ability_CastMember entity and mapping file, if only to be able to load the data with my current system. It won't be used for anything else (that I can think of at the moment). I have googled everything known to man, and have gone through the various docs on the Hibernate main site, but I am still not able to find what I need to create it.
Any help would be greatly appreciated.
Thanks!