Hi I'm using Hibernate 3.1. :
I have three tables: PO, Delatnost and TipDelatnosti. Relationships are: one-to-many from PO to Delatnost and one-to-many from TipDelatnsti to Delatnost.
My mapping files:
PO:
<?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 auto-import="true" default-lazy="false" package="yu.gov.sr.poreskauprava.rpo.domain"> <class name="PO" table="poreskiobveznik"> <id name="id" column="id" type="integer"> <generator class="identity"/> </id> <property name="pib" type="string"> <column name="pib"/> </property> <!-- veza ka Delatnostima. --> <set name="delatnosti" inverse="true" cascade="save-update"> <key column="poreskiobveznik_id"/> <one-to-many class="Delatnost"/> </set> </class> </hibernate-mapping> :
Delatnost:
<?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 auto-import="true" default-lazy="false" package="yu.gov.sr.poreskauprava.rpo.domain"> <class name="Delatnost" table="delatnost"> <id name="id" column="id" type="integer"> <generator class="identity"/> </id> <property name="ucesce" type="integer"> <column name="ucesce"/> </property> <many-to-one name="poreskiObveznik" column="poreskiobveznik_id" class="PO" not-null="true"/> <many-to-one name="tipDelatnosti" column="tipdelatnosti_id" class="TipDelatnosti" not-null="true"/> </class>
</hibernate-mapping>
And TipDelatnosti:
<?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 auto-import="true" default-lazy="false" package="yu.gov.sr.poreskauprava.rpo.domain"> <class name="TipDelatnosti" table="tipdelatnosti"> <id name="id" column="id" type="integer"> <generator class="identity"/> </id> <property name="sifra" type="string"> <column name="sifra"/> </property> <property name="naziv" type="string"> <column name="naziv"/> </property> <!-- veza sa Delatnostima. --> <set name="delatnosti" inverse="true" cascade="save-update"> <key column="tipdelatnosti_id"/> <one-to-many class="Delatnost"/> </set> </class>
</hibernate-mapping>
And of course POJO's which corresponds to those tables and relationships.
Problem is:
in some query when I try to access sifra in TipDelatnosti:
from PO p where p.delatnosti.tipdelatnosti.sifra = '1'
I get following error:
Caused by: org.springframework.orm.hibernate3.HibernateQueryException: could not
resolve property: sifra of: domain.Delatnost [selec
t count(*) from domain.PO p where p.delatnosti.tipDelatnosti.sifra = '1'
]; nested exception is org.hibernate.QueryException: could not resolve property: sifra of: domain.Delatnost ]
even though sifra is not property of Delatnost, than TipDelatnosti.
What's the problem?
Thanks in advance.
|