-->
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.  [ 7 posts ] 
Author Message
 Post subject: problem with join
PostPosted: Mon Aug 04, 2008 2:31 pm 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
hi ,
I have fallowing problem with querry.
Code:
20:29:04,191 ERROR PARSER:33 -  Path expected for join!
20:29:04,207 ERROR PARSER:33 -  Invalid path: 't.tnr'
20:29:04,207 ERROR PARSER:33 - <AST>:0:0: unexpected end of subtree
20:29:04,208 ERROR PARSER:33 -  left-hand operand of a binary operator was null
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [SELECT s FROM de.elaser.model.Struktur s LEFT JOIN fetch Teile t WHERE t.tnr=s.utnr ]


what it's mean : Path expected for join!???

thanks for help


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 4:55 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It is currently not possible to join classes in the way you try to do it. There is an issue in Hibernate JIRA for this (http://opensource.atlassian.com/project ... wse/HHH-16).

To be able to use a join you need to follow a mapped association using "dot" syntax. I guess this it the "path" that is expected. Eg. something like:

Code:
select s from Struktur s left join fetch s.teile


See http://www.hibernate.org/hib_docs/v3/re ... yhql-joins for more examples.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 5:07 pm 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
ok , I made it like you wrice, but I recive the same error :

Code:
Exception in thread "main" org.hibernate.QueryException: could not resolve property: teile of: de.elaser.model.Struktur [select s from de.elaser.model.Struktur s left join fetch s.teile]


I have declareted one-many relation in mapping files. How can I do it else?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 5:52 pm 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
here are mapping files :
Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="de.elaser.model">
   <class
      name="Teile"
      table="Teile"
   >
   
      <meta attribute="sync-DAO">false</meta>
      <id
         name="Id"
         type="integer"
         column="tnr"
      >
         
      </id>

      <property
         name="Bezeichnung"
         column="bezeichnung"
         type="string"
         not-null="false"
         length="255"
      />
      <property
         name="Me"
         column="me"
         type="string"
         not-null="false"
         length="10"
      />
      
      
   <set name="struktur" inverse="true">
      <key column="tnr"/>
      <one-to-many class="Struktur"/>
   </set>

   
   </class>   
</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="de.elaser.model">
   <class
      name="Struktur"
      table="Struktur"
   >
      <meta attribute="sync-DAO">false</meta>
      <id
         name="Id"
         type="integer"
         column="id"
      >
      
      </id>

      <property
         name="otnr"
         column="otnr"
         type="integer"
         
         length="10"
      />
      <property
         name="utnr"
         column="utnr"
         type="integer"
         
         length="10"
      />
      <property
         name="menge"
         column="menge"
         type="integer"
         
         length="10"
      />
      
   

   </class>
      
</hibernate-mapping>


table teile 1:n Struktur


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 6:21 pm 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
after changing few things i recive fallowing error :
Code:
Exception in thread "main" 00:19:21,555 ERROR JDBCExceptionReporter:78 - Unknown column 'struktur0_.tnr' in 'field list'



my mapping files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="de.elaser.model">
   <class
      name="Struktur"
      table="Struktur"
   >
      
      <id
         name="Id"
         type="integer"
         column="id"
      >
      
      </id>

      <property
         name="Otnr"
         column="otrn"
         type="integer"
         
         length="10"
      />
      <property
         name="Utnr"
         column="utnr"
         type="integer"
         
         length="10"
      />
      <property
         name="Menge"
         column="menge"
         type="integer"
         
         length="10"
      />
      <many-to-one
         name="teile"
         column="tnr"
         class="Teile"
         not-null="true">
      </many-to-one>
   

   </class>
      
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="de.elaser.model">
   <class
      name="Teile"
      table="Teile"
   >
   
      <meta attribute="sync-DAO">false</meta>
      <id
         name="Id"
         type="integer"
         column="tnr"
      >
         
      </id>

      <property
         name="Bezeichnung"
         column="bezeichnung"
         type="string"
         not-null="false"
         length="255"
      />
      <property
         name="Me"
         column="me"
         type="string"
         not-null="false"
         length="10"
      />
      
      
   <set name="struktur" inverse="true">
      <key column="tnr"/>
      <one-to-many class="Struktur"/>
   </set>

   
   </class>   
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 1:51 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It seems like your are slowly getting there. The remaining problem is that your "Struktur" table doesn't have a column called 'tnr'. From the query in your first post it looks like the column is named 'utnr'. So, your <many-to-one> mapping should probably be:

Code:
<many-to-one
     name="teile"
     column="utnr"
     class="Teile"
     not-null="true">
</many-to-one>


This creates another problem, since the 'utnr' column has already been mapped as a regular property. Hibernate will complain about this being a duplicate mapping and you need to remove it. Now, this will create yet another problem with your existing code since Struktur.setUtnr()/getUtnr() will no longer work. Calls to these methods need to be replaced with calls to Struktur.setTeile()/getTeile().


Top
 Profile  
 
 Post subject: Re: problem with join
PostPosted: Wed Jun 02, 2010 2:46 am 
Newbie

Joined: Sat Mar 27, 2010 2:43 am
Posts: 8
@patrick1984 did you find any solution to your problem. If yes then please post it cause i too am facing a similar type of problem.

I have 2 questions while performing the outer join operation of 2 hibernate mapping files
1. Does both of the hibernate mapping files must have some info about association like <many-to-one> and <one-to-many>
2. Does left outer join using the following query
FROM TableVersionLogData as v left outer join v.versionID
get all the columns in the other table with which this table is performing the outer join?

Hibernate files which i am using are namely
TableVersionLogData.hbm.xml
TableVersion.hbm.xml

TableVersion.hbm.xml (maps to TableVersionData.java )is the parent table that has VersionID as the primary key
TableVersionLog.hbm.xml(maps to TableVersionLogData.java ) is the table that has versionID as the foreign key in the database and i have added the follwing code in TableVersionLog.hbm.xml
Code:
"<many-to-one name="versionID" column="versionID" class="TableVersionData"/>"


but when i run the above query i get the error saying that the columns in the TableVersion.hbm.xml cannot be seen from TableVersionLog.hbm.xml

Exception is
Code:
"org.hibernate.QueryException: could not resolve property: versionName of: TableVersionLogData [ FROM  TableVersionLogData as v left outer join v.versionID ] "


Could any one please let me know where i am making a mistake


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.