Hi!
Inserting Mitspieler doesn't make a problem, but inserting a Tippgemeinschaft still does:
No persister for: java.lang.Long
A Mitspieler(Player) can have several Teams (Tippgemeinschaft) to manage and a Team must have an admin.
Hier is my mapping file:
Code:
<class name="tippspiel.Mitspieler" table="MITSPIELER">
<id name="id" unsaved-value="null">
<column name="ID" sql-type="bigint(20)" not-null="true"/>
<generator class="native"/>
</id>
<set name="adminTippgemeinschaften" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="ADMIN_ID"/>
<one-to-many class="tippspiel.Tippgemeinschaft"/>
</set> </class>
<class name="tippspiel.Tippgemeinschaft" table="TIPPGEMEINSCHAFT">
<id name="id" type="long" unsaved-value="null">
<column name="ID" sql-type="bigint(20)" not-null="true"/>
<generator class="native"/>
</id>
<many-to-one name= "adminId" class = "tippspiel.Mitspieler" column="ADMIN_ID" not-null="true" unique="true"/> </class>
Here are my Beans:
Code:
public class Mitspieler {
private long id;
private String name;
private String email;
private String passwort;
...}
public class Tippgemeinschaft {
private long id;
private String name;
private long adminId;
...}
And this is how I try to insert Tippgemeinschaft:
Code:
Transaction tx = session.beginTransaction();
Mitspieler tom = new Mitspieler();
tom.setName("Benny");
tom.setEmail("benny@gmx.de");
tom.setPasswort("secret^4!");
session.save(tom);
tx.commit();
//Get Benny's Id = adminId (and cast it to long) ...
Transaction tx3 = session.beginTransaction();
// I want Benny to admin this Team(Tippgemeinschaft):
Tippgemeinschaft hsv = new Tippgemeinschaft();
hsv.setName("HSV Fanclub");
hsv.setAdminId(adminId);
session.save(hsv);
tx3.commit();