-->
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: sql-query mapping problem
PostPosted: Wed Jul 20, 2005 2:47 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
I have below <sql-query/> element present in one of the hibernate mapping file.

Code:
<sql-query name="metaobject.findByPartialKey_metaobject_for_structure">
          <return class="Metaobject" />
          select metaobjectno, structureno, name, description from metaobject where structureno = :structureno
     </sql-query>

Metaobject class definition is something like this --

Code:
<class name="Metaobject" table="metaobject">
          <composite-id name="comp_id" class="MetaobjectPK">
               <key-property name="metaobjectno" column="metaobjectno" type="java.lang.Integer" length="3" />
               <key-property name="structureno" column="structureno" type="java.lang.Integer" length="3" />
          </composite-id>
          <property name="name" column="name" type="java.lang.String" length="64" lazy="true" />
          <property name="description" column="description" type="java.lang.String" length="128" lazy="true" />
          <property name="lookup" column="lookup" type="java.lang.Character" length="1" lazy="true" />
          <property name="persistent" column="persistent" type="java.lang.Character" length="1" lazy="true" />
....
....
</class>


When I try to execute the sql-query, hibernate throws an exception as below --

Code:
Invalid column name: lookup
   at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
   at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
   at com.microsoft.jdbc.base.BaseResultSet.getColumnOrdinal(Unknown Source)
   at com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
   at org.hibernate.type.CharacterType.get(CharacterType.java:23)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
   at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
   at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1690)
   at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:991)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:942)
   at org.hibernate.loader.Loader.getRow(Loader.java:855)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:305)
   at org.hibernate.loader.Loader.doQuery(Loader.java:412)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
   at org.hibernate.loader.Loader.doList(Loader.java:1593)
   at org.hibernate.loader.Loader.list(Loader.java:1577)
   at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
   at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
   at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)



The obvious reason is the query does not have 'lookup' column in projection. So how do I configure hibernate mapping in such a way that it will set only the sql projection columns into corresponding mapping class. I read http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazyproperties but lazy=true, didnt solve problem either.

Please help!!

Regards
Nilesh


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 6:07 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
I got this resolved using instrument ANT task to compile value objects. But this doesnt seem to be a good option 'coz now every time when value objects are compiled, I need to run instrument ANT task.

Is there any other way of solving this problem? Please help!


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.