-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Exception:Invalid path
PostPosted: Fri Mar 31, 2006 5:03 am 
Newbie

Joined: Thu Feb 02, 2006 10:42 am
Posts: 5
Location: Slovenia
Hello.

If I execute the following hql:
Code:
select pogodbe.delojemalci.delojemalciid
  from si.rais.eplace.hibernate.Pogodbepodatki

I get my results.

But, if I try to filter the result like this:
Code:
select *
  from si.rais.eplace.hibernate.Pogodbepodatki
where pogodbe.delojemalci.delojemalciid = 25391

I get an "Invalid path" error.

The field is the same in select and in where clause! ??

Using an alias for the table helps, but in my case, I can't use an alias (have a generated HQL text).


Hibernate version: 3.1.rc2

Full stack trace of any exception that occurs:
10:44:02,722 ERROR [PARSER] Invalid path: 'pogodbe.delojemalci.delojemalciid'
10:44:02,722 ERROR [PARSER] <AST>:0:0: unexpected end of subtree
10:44:02,722 ERROR [PARSER] left-hand operand of a binary operator was null
10:44:02,738 INFO [STDOUT] Hibernate Exception:Invalid path: 'pogodbe.delojemalci.delojemalciid' [select pogodbe.delojemalci.delojemalciid
from si.rais.eplace.hibernate.Pogodbepodatki
where pogodbe.delojemalci.delojemalciid = 25391] ; Invalid path: 'pogodbe.delojemalci.delojemalciid'

Name and version of the database you are using:
ORACLE 10.2

The generated SQL (show_sql=true):
No generated SQL yet


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 1:37 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
* isn't HQL. Try
Code:
from si.rais.eplace.hibernate.Pogodbepodatki
where pogodbe.delojemalci.delojemalciid = 25391


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 8:03 am 
Newbie

Joined: Thu Feb 02, 2006 10:42 am
Posts: 5
Location: Slovenia
Still it doesn't work. Now I get:

Code:
12:58:50,466 INFO  [STDOUT] Hibernate Exception:could not resolve property: delojemalci of: si.rais.eplace.hibernate.Pogodbepodatki [from si.rais.eplace.hibernate.Pogodbepodatki
where pogodbe.delojemalci.delojemalciid = 25391] ;


It seems that hibernate takes the first entity in the where condition (pogodbe) as the alias for the table in the from section, rather than a property of it. "delojemalci" is a property of the pogodbe table, which is a property of the pogodbepodatki table.

That's why an alias helps and the following hql works:
Code:
from si.rais.eplace.hibernate.Pogodbepodatki ppd
where ppd.pogodbe.delojemalci.delojemalciid = 25391


As I mentioned before, my HQL is generated in an application, so I cannot use an alias, but I can modify the where condition. Is there a way to tell hibernate, that the first table in the where condition is not an alias, but a property?

This is my mapping file:
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" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Fri Feb 03 12:48:18 CET 2006                         -->
<hibernate-mapping package="si.rais.eplace.hibernate">

    <class name="Pogodbepodatki" table="PLC.POGODBEPODATKI">
        <id name="dokumentiid" column="DOKUMENTIID" type="java.lang.Long">
            <generator class="sequence">
         <param name="sequence">PLC.SEQ_DOKUMENTI</param>
            </generator>
        </id>

        <property name="trenutekvnosa" column="TRENUTEKVNOSA" type="java.util.Date"  not-null="true" />
        <property name="trenutekspremembe" column="TRENUTEKSPREMEMBE" type="java.util.Date"  not-null="true" />
        <property name="veljaod" column="VELJAOD" type="java.util.Date"  not-null="true" />
        <property name="veljado" column="VELJADO" type="java.util.Date" />
        <property name="staneksa" column="STANEKSA" type="java.lang.Short"  not-null="true" />
        <property name="znesekpogodbe" column="ZNESEKPOGODBE" type="java.lang.Double" />
        <property name="vrednosture" column="VREDNOSTURE" type="java.lang.Double" />
        <property name="stevilotock" column="STEVILOTOCK" type="java.lang.Float" />
        <property name="poskusnodelomesecev" column="POSKUSNODELOMESECEV" type="java.lang.Short"  not-null="true" />
        <property name="odpovednirokmesecev" column="ODPOVEDNIROKMESECEV" type="java.lang.Short"  not-null="true" />
        <property name="krajopravljanjadela" column="KRAJOPRAVLJANJADELA" type="java.lang.String" />
        <property name="tedenskaobveznostur" column="TEDENSKAOBVEZNOSTUR" type="java.lang.Float"  not-null="true" />
        <property name="osnovnidopustdni" column="OSNOVNIDOPUSTDNI" type="java.lang.Short"  not-null="true" />
        <property name="urepriznanainvalidnost" column="UREPRIZNANAINVALIDNOST" type="java.lang.Float" />
        <property name="uporabnikiid_spremenil" column="UPORABNIKIID_SPREMENIL" type="java.lang.Integer"  not-null="true" />
        <many-to-one name="uporabniki_spremenil" column="UPORABNIKIID_SPREMENIL" class="si.rais.jo.data.hibernate.Uporabniki" insert="false" update="false"/>
        <many-to-one name="dlmpodatki" column="DLMPODATKIID" class="Dlmpodatki"  not-null="true" />
        <many-to-one name="organizacijskeenote" column="ORGANIZACIJSKEENOTEID" class="Organizacijskeenote"  not-null="true" />
        <many-to-one name="pogodbe" column="DOKUMENTIID_POGODBE" class="Pogodbe" />
        <many-to-one name="dokumenti" column="DOKUMENTIID" class="Dokumenti" insert="false" update="false"/>

       <filter name="filterpodrejene" condition="exists (select 1 from plc.pogodbe where dokumentiid_pogodbe = pogodbe.dokumentiid and pogodbe.organizacijskeenoteid in(:pravicepodrejenihoe))"/>
    </class>
   
</hibernate-mapping>


and another one:

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" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Fri Feb 03 12:48:18 CET 2006                         -->
<hibernate-mapping package="si.rais.eplace.hibernate">

    <class name="Pogodbe" table="PLC.POGODBE">
        <id name="dokumentiid" column="DOKUMENTIID" type="java.lang.Long">
            <generator class="sequence">
         <param name="sequence">PLC.SEQ_DOKUMENTI</param>
            </generator>
        </id>

        <property name="trenutekvnosa" column="TRENUTEKVNOSA" type="java.util.Date"  not-null="true" />
        <property name="trenutekspremembe" column="TRENUTEKSPREMEMBE" type="java.util.Date"  not-null="true" />
        <property name="veljaod" column="VELJAOD" type="java.util.Date"  not-null="true" />
        <property name="veljado" column="VELJADO" type="java.util.Date" />
        <property name="oznaka" column="OZNAKA" type="java.lang.String"  not-null="true" />
        <property name="dolocennedolocencas" column="DOLOCENNEDOLOCENCAS" type="java.lang.String"  not-null="true" />
        <property name="predvidenkonec" column="PREDVIDENKONEC" type="java.util.Date" />
        <property name="uporabnikiid_spremenil" column="UPORABNIKIID_SPREMENIL" type="java.lang.Integer"  not-null="true" />
        <many-to-one name="uporabniki_spremenil" column="UPORABNIKIID_SPREMENIL" class="si.rais.jo.data.hibernate.Uporabniki" insert="false" update="false"/>
        <many-to-one name="delojemalci" column="DELOJEMALCIID" class="Delojemalci"  not-null="true" />
        <many-to-one name="sifvrstepogodb" column="SIFVRSTEPOGODBID" class="Sifvrstepogodb"  not-null="true" />
        <many-to-one name="stranke" column="ORGANIZACIJSKEENOTEID" class="Stranke"  not-null="true" />
        <many-to-one name="dokumenti" column="DOKUMENTIID" class="Dokumenti" insert="false" update="false"/>

       <filter name="filterpodrejene" condition="organizacijskeenoteid in (:pravicepodrejenihoe)"/>
    </class>
   
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 5:47 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I believe that "this" is an implicit alias for the current table. See if this works:
Code:
from si.rais.eplace.hibernate.Pogodbepodatki
where this.pogodbe.delojemalci.delojemalciid = 25391
If it does, you could change whatever HQL-generating code you're using to put "this." prefixes in. Or alternatively, change it to always add an alias.

Generally, if you're building up queries automatically, Criteria is a better choice than HQL. They're designed to be used in this way, where's HQL is designed to be written in one lump.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 10:19 am 
Newbie

Joined: Thu Feb 02, 2006 10:42 am
Posts: 5
Location: Slovenia
Unfortunately "this" doesn't work either. It reports an "Invalid path" error.

It took some time, but I managed to change the application to always use an alias and solved my problem.

Thank you very much for your help!

Also took a look at Criteria. Very nice! Looks like I overlooked this chapter completely :).


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.