-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Strnage thing in many to many mapping
PostPosted: Sat Nov 11, 2006 5:47 am 
Newbie

Joined: Thu Aug 17, 2006 8:59 am
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.