Hibernate version: 3.0
Mapping Dateien:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="orm">
<class name="ObjectItem" table="OBJ_ITEM">
<meta attribute="class-description">Represents an Object Item</meta>
<id name="id" column="obj_item_id" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="categoryCode" column="cat_code" type="string" length="6" not-null="true"/>
<property name="name" column="name" type="string" length="100" not-null="true"/>
<property name="alternateIdentificationText" column="altn_identific_txt" type="string" length="255"/>
<property name="ownerId" column="owner_id" type="long" not-null="true"/>
<property name="updateSeqNo" column="update_seqnr" type="long" not-null="true"/>
<set name="capability" lazy="false" inverse="true" cascade="all">
<key column="obj_item_id"/>
<one-to-many class="ObjectItemCapability" />
</set>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="orm">
<class name="ObjectItemCapability" table="OBJ_ITEM_CAPAB" >
<meta attribute="class-description">Represents a Object Item Capability</meta>
<id name="id" column="obj_item_capab_ix" type="java.lang.Long">
<generator class="native"/>
</id>
<many-to-one name="objectItem" class="ObjectItem"
column="obj_item_id"
update="false"
insert="true"
not-null="true" />
<many-to-one name="capability" class="Capability"
column="capab_id"
update="false"
insert="true"
not-null="true"
cascade="all"/>
<property name="missionPrimacyCode" column="msn_primacy_code" type="string" length="6"/>
<property name="reportingDataId" column="rptd_id" type="long"/>
<property name="ownerId" column="owner_id" type="long" not-null="true"/>
<property name="updateSeqNo" column="update_seqnr" type="long" not-null="true"/>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="orm">
<class name="Capability" table="CAPAB">
<meta attribute="class-description">Represents a Capability</meta>
<id name="id" column="capab_id" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="categoryCode" column="cat_code" type="string" length="6" not-null="true"/>
<property name="subCategoryCode" column="sub_cat_code" type="string" length="6"/>
<property name="dayNightCode" column="day_night_code" type="string" length="6"/>
<property name="unitOfMeasureCode" column="uom_code" type="string" length="6"/>
<property name="ownerId" column="owner_id" type="long" not-null="true"/>
<property name="updateSeqNo" column="update_seqnr" type="long" not-null="true"/>
<set name="storageCapabilities" table="STORAGE_CAPAB">
<key column="storage_capab_id"/>
<many-to-many column="mat_type_id" class="MaterialType" unique="true"/>
</set>
</class>
</hibernate-mapping>
Bin noch recht unerfahren in sachen hibernate und habe momentan folgendes Problem: Ich lege mir ein Objekt vom Typ
ObjectItem an, indem wiederum ein Objekt der Klasse
ObjektItemCapability und in dem wiederum ein Objekt
Capability. Beim persistieren wird mir aber ein unexpected row count zurückgegeben. ein blick in die logs von hsql ergab, dass kein insert in die tabelle
ObjektItemCapability stattfindet. weiß jemand warum ich das objektgebilde nicht in die datenbank bekomme?
[/code]