access to data of a referenced table
by elyes sallem
Hello,
a have a table TmpAjustCpe which references the table projet
here is the mapping for this relation in the xml file projet.xml :
<set name="tmpAjustCpes" inverse="true" >
<key>
<column name="PRJ_ID" precision="7" scale="0"
not-null="true" />
</key>
<one-to-many class="com.thales.project.TmpAjustCpe" />
</set>
in the bean associated to projet , i wanna access a property of TmpAjustCpe
for this i implemented this getter
public BigDecimal getDernierCpeEmporte() {
if(getProjet().getTmpAjustCpes()!=null){
for (Iterator<TmpAjustCpe> iterator =
getProjet().getTmpAjustCpes().iterator(); iterator.hasNext();) {
TmpAjustCpe tmpAjustCpe = (TmpAjustCpe) iterator.next();
return tmpAjustCpe.getDernierCpeEmporte();
}
}
return BigDecimal.ZERO;
}
the problem is that the data related to TmpAjustCpe have not been loaded
any one have an idea what should i do in the xml file to load this property,
Regards
Elyes
15 years, 8 months
HACK: org.hibernate.MappingException: Repeated column in mapping
by Ing. Arturo Frappé Muñoz
Lords & Ladies, this hack is for Hibernate 3.3.1-GA, and solves an
error like this:
org.hibernate.MappingException: Repeated
column in mapping for entity: org.intresting.MyClass column: HACKME_COLUMN
(should be mapped with insert="false"
update="false")
When you use a discriminator column -
with SingleTable inheritance -,
like this:
<class
name="MyClass" .... >
<composite-id name="id" class="MyClassId">
. . .
<key-property
name="hackmecolumn" type="short">
<column name="HACKME_COLUMN"/>
</key-property>
...
</composite-id>
<discriminator column="HACKME_COLUMN" />
...
<subclass name="VeryIntrestingClass"
discriminator-value="21" />
</class>
The hack is: change the case of <discriminator column> to
lowercase.
<discriminator column="hackme_column"
/>
- y santo remedio -
15 years, 9 months