-->
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.  [ 2 posts ] 
Author Message
 Post subject: Iterate with filter on persistent collection error on hb 3.1
PostPosted: Mon Jan 16, 2006 8:07 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.1
Mapping documents:
PetOwner
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="pethotel">
   <class
      name="PetOwner"
      table="PetOwner"
   >   
      <id
         column="ownerId"
         name="ownerId"
         type="java.lang.Integer"
      >
         <generator class="increment">
         </generator>
      </id>   
      <property
         name="name"
         column="name"
         type="string"
         not-null="true"
        >
      </property>
      <set
         inverse="true"
         lazy="true"
         name="PetSet"
      >
         <key column="ownerId" />
         <one-to-many class="pethotel.Pet" />
      </set>   
   </class>
</hibernate-mapping>

Pet
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="pethotel">
   <class
      name="Pet"
      table="Pet"
   >   
      <id
         name="petId"
         type="java.lang.Integer"
      >
          <column
             name ="petId"
             length="30"
          />
         <generator class="increment">
         </generator>
      </id>   
      <property
         name="name"
         column="name"
         type="string"
         not-null="true"
        >
      </property>
      <many-to-one
         name="ownerId"
         class="pethotel.PetOwner"
         not-null="true"
      >
         <column name="ownerId"/>
      </many-to-one>
   </class>
</hibernate-mapping>

Config:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.cglib.use_reflection_optimizer">true</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.url">jdbc:postgresql:pethotel</property>
        <property name="hibernate.connection.username">atorres</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.show_sql">true</property>
        <mapping resource="pethotel/PetOwner.hbm.xml" />
        <mapping resource="pethotel/Pet.hbm.xml" />
    </session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
This is a main method implementation (stand alone)
Code:
   Configuration _configuration=new Configuration().configure();
   SessionFactory _sessionFactory = _configuration.buildSessionFactory();
   Session sess = _sessionFactory.openSession();
      
      
   List l = sess.createQuery("select PetOwner from pethotel.PetOwner as PetOwner ").list();
   for (Iterator i=l.iterator();i.hasNext();) {
      PetOwner po = (PetOwner) i.next();
      Query q2=sess.createFilter(po.getPetSet()," order by this.name ");
      for (Iterator it = q2.iterate();it.hasNext();) {
         Object ob2=it.next(); //<- exception point
         System.out.println(ob2);
      }
   }

Full stack trace of any exception that occurs:
SEVERE: O nome da coluna col_0_0_ não foi encontrado.
org.hibernate.exception.GenericJDBCException: could not execute query using iterate
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:410)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:310)
at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:170)
at org.hibernate.impl.SessionImpl.iterateFilter(SessionImpl.java:1422)
at org.hibernate.impl.CollectionFilterImpl.iterate(CollectionFilterImpl.java:38)
at org.jtri.report.HBDatasource.main(HBDatasource.java:485)
Caused by: org.postgresql.util.PSQLException: O nome da coluna col_0_0_ não foi encontrado.
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:673)
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getInt(AbstractJdbc1ResultSet.java:496)
at org.hibernate.type.IntegerType.get(IntegerType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:95)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:217)
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:93)
at org.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:58)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:390)
... 5 more
Name and version of the database you are using:
Postgres 7
The generated SQL (show_sql=true):
Hibernate: select pet0_.petId as petId1_, pet0_.name as name1_, pet0_.ownerId as ownerId1_ from Pet pet0_ where pet0_.ownerId = ? order by pet0_.name
Debug level Hibernate log excerpt:

My Iterate command with filter works fine with hibernate 3, but now it just stoped working with this exception.
I steped inside hibernate's code and, I don't know why, queryTranslator.getColumnNames() is returning this col_0_0_ column name in a ? query. If it's a bug, a will file it. I use iterate with filter very often on my applications. What do you folks think about it?

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 8:14 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
It may be HHH-1308 bug right?
http://opensource2.atlassian.com/projec ... e/HHH-1308
So I will have to wait until Hibernate 3.11 to get an stable version...
I think it's better keep version 3.0 instead, it's stable.
Good that's a sovled bug!

_________________
Alexandre Torres
--------------------


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