Hello!
First the facts:
Hibernate version: 3.2.6.ga
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="itcjb.bellerophon2.business.domain.balance.BalanceCategoryValue"
table="balancecategoryvalue"
>
<id
name="id"
column="IDbalanceCategoryValue"
type="long"
unsaved-value="0"
>
<generator class="identity">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-BalanceCategoryValue.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<many-to-one
name="balanceCategory"
class="itcjb.bellerophon2.business.domain.balance.BalanceCategory"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="balanceCategoryID"
not-null="true"
/>
<many-to-one
name="balanceValue"
class="itcjb.bellerophon2.business.domain.balance.BalanceValue"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="balanceValueID"
not-null="false"
/>
<many-to-one
name="parentBalanceCategoryValue"
class="itcjb.bellerophon2.business.domain.balance.BalanceCategoryValue"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="parentBalanceCategoryValueID"
not-null="false"
/>
<bag
name="listOfChildBalanceCategoryValues"
lazy="false"
inverse="true"
cascade="save-update"
>
<key
column="parentBalanceCategoryValueID"
>
</key>
<one-to-many
class="itcjb.bellerophon2.business.domain.balance.BalanceCategoryValue"
/>
</bag>
<bag
name="listOfSablItems"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
>
<key
column="balanceCategoryValueID"
>
</key>
<one-to-many
class="itcjb.bellerophon2.business.domain.financialYear.SaBLItem"
/>
</bag>
<property
name="amount"
type="itcjb.bellerophon2.business.domain.amount.AmountUserType"
update="true"
insert="true"
column="amount"
/>
<property
name="lastModified"
type="java.util.GregorianCalendar"
update="true"
insert="true"
column="lastModified"
/>
<many-to-one
name="modifier"
class="itcjb.bellerophon2.business.domain.user.User"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="modifierID"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-BalanceCategoryValue.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Name and version of the database you are using: MySQL 5.0
The generated SQL (show_sql=true):Code:
select listofchil0_.parentBalanceCategoryValueID as parentBa4_1_, listofchil0_.IDbalanceCategoryValue as IDbalanc1_1_, listofchil0_.IDbalanceCategoryValue as IDbalanc1_54_0_, listofchil0_.balanceCategoryID as balanceC2_54_0_, listofchil0_.balanceValueID as balanceV3_54_0_, listofchil0_.parentBalanceCategoryValueID as parentBa4_54_0_, listofchil0_.amount as amount54_0_, listofchil0_.lastModified as lastModi6_54_0_, listofchil0_.modifierID as modifierID54_0_ from balancecategoryvalue listofchil0_ where listofchil0_.parentBalanceCategoryValueID=?
Problem: If I try to get an amount (is a UserType (works perfectly in other classes)), of a Category that has no parent, I get null. But if i execute the sql statement manually at the database. I get the correct values.
I tested a little bit and set the parentBalanceCategoryValueID to something else, I get the correct value.
Can anyone help me? - I really don't know where my mistake is!
Thank you
Joerg Bergner