-->
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.  [ 3 posts ] 
Author Message
 Post subject: Error in HQL with hibernate 3.3.1 that it worked in 3.2.2
PostPosted: Tue Oct 14, 2008 1:57 pm 
Newbie

Joined: Sun Oct 12, 2008 9:17 am
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3.1 but it worked in 3.2.2

Mapping documents:

<class name="com.mdagen.rallie.model.Equipo" table="EQUIPOS" lazy="false">

<id name="idEquipo"
type="long">
<column name="ID_EQUIPO"/>
</id>

...
<set name="marcasEqus" cascade="save-update" outer-join="true"
table="EQUIPOS_MARCAS" lazy="false">
<key column="ID_EQUIPO"/>
<many-to-many class="com.mdagen.rallie.model.Marca" outer-join="true"
column="ID_MARCA" lazy="false"/>
</set>
</class>

<class name="com.mdagen.rallie.model.Marca" table="MARCAS" lazy="false">

<id name="idMarca"
type="long">
<column name="ID_MARCA"/>
</id>

</class>

</hibernate-mapping>






Code between sessionFactory.openSession() and session.close():
The hql is
"from com.mdagen.rallie.model.Equipo as ta where ta.marcasEqus.idMarca = ? "


Full stack trace of any exception that occurs:

Caused by: org.springframework.orm.hibernate3.HibernateQueryException: illegal attempt to dereference collection [equipo0_.ID_EQUIPO.marcasEqus] with element property reference [idMarca] [from com.mdagen.rallie.model.Equipo as ta where ta.marcasEqus.idMarca = ? ]; nested exception is org.hibernate.QueryException: illegal attempt to dereference collection [equipo0_.ID_EQUIPO.marcasEqus] with element property reference [idMarca] [from com.mdagen.rallie.model.Equipo as ta where ta.marcasEqus.idMarca = ? ]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917)
at com.mdagen.rallie.dao.hibernate.EquipoDAOHibernate.getEquipos(EquipoDAOHibernate.java:99)

Name and version of the database you are using:

MySQL 5.0.
The generated SQL (show_sql=true):


I have a little web application with struts 1 spring 2.5.5 and hibernate 3.2.2 who works fine (relatively). But when i have migrated to hibernate 3.3.1 i have and error in hql i can't understand.

I would appreciate any help

Rodolfo


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2008 3:42 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Use a join for your collection:

Code:
from com.mdagen.rallie.model.Equipo as ta left join ta.marcasEqus as equs where equs.idMarca = ?


Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2008 4:21 pm 
Newbie

Joined: Sun Oct 12, 2008 9:17 am
Posts: 9
Thanks a lot Christophe, the problem has been solved, but if I have more criteria in the query how could I resolve it?. perhanps doing a new join or with te same join I could?

Thanks

Rodolfo


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