Hibernate version: 2
Mapping documents: Aufgabe.hbm.xml , Pruefung.hbm.xml, Kategorie.hbm.xml
Code between sessionFactory.openSession() and session.close(): ----
Full stack trace of any exception that occurs: ----
Name and version of the database you are using: MySQL 4.0.21
The generated SQL (show_sql=true):
insert into Aufgaben (ueberschrift, inhalt, bild1, bild2) values (?, ?, ?, ?)
select this.aufgabenID as aufgabenID2_, this.ueberschrift as uebersch2_2_, this.inhalt as inhalt2_, this.bild1 as bild12_, this.bild2 as bild22_, kategorie1_.kategorienID as kategori1_0_, kategorie1_.name as name0_, pruefung2_.pruefungenID as pruefung1_1_, pruefung2_.erscheinungsjahr as erschein2_1_, pruefung2_.fachbereich as fachbere3_1_, pruefung2_.pruefungsPDF as pruefung4_1_, pruefung2_.pruefungsPDF2 as pruefung5_1_ from Aufgaben this left outer join Kategorien kategorie1_ on this.aufgabenID=kategorie1_.kategorienID left outer join Pruefungen pruefung2_ on this.aufgabenID=pruefung2_.pruefungenID where 1=1
Debug level Hibernate log excerpt: logging not configured yet
Hi all,
i have a problem with two one-to-one associations. When i want to save my Aufgaben object which holds two one-to-one associations, one to Kategorie and one to Pruefung, the keys of the associated objects are not saved into the db. I have searched this forum for similar problems but couldn't find an answer to my problem. Can Hibernate not store the id's of one-to-one associated objects? Or does Hibernate not note that the associations are properties of the parent object too?
Would be nice if someone could help me! Below are my DB Tables and the mapping files.
Thanks in advance.
Torben
Database Tables
--------------------
Code:
Table Aufgaben (
aufgabenID INTEGER PK AUTO_INCREMENT,
kategorienID INTEGER FK,
pruefungenID INTEGER FK,
ueberschrift VARCHAR,
inhalt VARCHAR
)
Table Kategorien (
kategorienID INTEGER PK AUTO_INCREMENT,
name VARCHAR
)
Table Pruefungen (
pruefungenID INTEGER PK AUTO_INCREMENT,
erscheinungsjahr INTEGER,
fachbereich VARCHAR
)
Mapping files
---------------
Aufgabe.hbm.xml:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="cactus.dom.Aufgabe" table="Aufgaben">
<id name="aufgabenID" column="aufgabenID" type="int">
<generator class="native"/>
</id>
<property name="ueberschrift" column="ueberschrift"
type="string" not-null="true"/>
<property name="inhalt" column="inhalt"
type="string" not-null="true"/>
<one-to-one
name="kategorie"
class="cactus.dom.Kategorie"
cascade="none"
foreign-key="kategorienId"/>
<one-to-one
name="pruefung"
class="cactus.dom.Pruefung"
cascade="none"
foreign-key="pruefungenId"/>
</class>
</hibernate-mapping>
Kategorie.hbm.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="cactus.dom.Kategorie" table="Kategorien">
<id name="kategorienID" column="kategorienID" type="int">
<generator class="native"/>
</id>
<property name="name" column="name"
type="string" not-null="true"/>
</class>
</hibernate-mapping>
Pruefung.hbm.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="cactus.dom.Pruefung" table="Pruefungen">
<id name="pruefungenID" column="pruefungenID" type="int">
<generator class="native"/>
</id>
<property name="erscheinungsjahr" column="erscheinungsjahr"
type="int" not-null="true"/>
<property name="fachbereich" column="fachbereich"
type="string" not-null="true"/>
</class>
</hibernate-mapping>