-->
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: cast issue on simple query
PostPosted: Fri Sep 25, 2009 12:01 pm 
Newbie

Joined: Fri Sep 25, 2009 11:47 am
Posts: 1
Hi everyone. I cannot execute a "simple" query. What am I wrong?

Utenza mapping:
Code:
<hibernate-mapping package="domain">
   <class name="Utenza">
      <id name="id">
         <generator class="native" />
      </id>
      <property name="nome" />
      <set name="tabulati" lazy="true" inverse="true" cascade="all" >
         <key column="utenza" />
         <one-to-many class="Tabulato" />
      </set>

   </class>
</hibernate-mapping>


Tabulato mapping:
Code:
<hibernate-mapping package="domain" >
   <class name="Tabulato">
      <id name="id">
         <generator class="native" />
      </id>
      <property name="archiviazione" />
      <many-to-one name="utenza" column="utenza" class="Utenza" not-null="true"/>
      <set name="chiamate" lazy="true" inverse="true" cascade="all">
         <key column="tabulato" />
         <one-to-many class="Chiamata" />
      </set>
   </class>
</hibernate-mapping>

The following query:
Code:
List<Utenza> utenze = s.createQuery("from Utenza U, Tabulato T where U.tabulati.invio is null").list();

gives the following error:
Code:
illegal attempt to dereference collection [utenza0_.id.tabulati] with element property reference [invio] [from domain.Utenza U, domain.Tabulato T where U.tabulati.invio is null]
...

and the following query:
Code:
List<Utenza> utenze = s.createQuery("from Utenza U, Tabulato T where T.utenza = U.id and T.invio is null").list();

gives the following error:
Code:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to domain.Utenza



What's wrong?
I'd to retrieve all "Tabulato" which have invio = null joined with their Utenza.

Thx for any help


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