-->
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: createSQLQuery error
PostPosted: Wed Feb 01, 2006 5:36 pm 
Newbie

Joined: Sat Feb 26, 2005 11:45 am
Posts: 13
Location: Stockholm, Sweden
Im getting grey hair....

Hibernate version: 3.0

Hi, I have a problem using a simple createSQLQuery method in a dao class that extendes HibernateDaoSupport.
I can see its complaining about my id column in my Ad class. the id variable is a String as you can see in my hib-mapping doc below but this should not be a problem....

The code looks like this:
return getSession().createSQLQuery("select * from ad")
.addEntity("ad", Ad.class)
.list();

the exception show:
Hibernate: select * from ad
2006-02-01 22:31:51,509 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL E
rror: 0, SQLState: S0022>
2006-02-01 22:31:51,509 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Colu
mn 'id0_' not found.>
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificExceptio
n(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter
.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
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)
at com.buysell.server.dao.hibernate.AdDaoHibernate.executeSql(Unknown So
urce)
at com.buysell.client.service.AdServiceImpl.executeSql(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti

My mapping document
<id
name="id"
column="id"
type="java.lang.String"
length="32"
unsaved-value="null"
>
<generator class="uuid.hex">
</generator>
</id>

_________________
kmike


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 7:26 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You want the "addEntity(Ad.class)" form of that method. The "addEntity("ad", Ad.class)" form is looking for an alias "ad" in your SQL string, which you're not supplying. The alternative would be to change your SQL string to "select {ad.*} from ad".


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.