-->
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: undefined alias
PostPosted: Mon Jun 13, 2005 11:24 am 
Newbie

Joined: Mon Jun 13, 2005 5:14 am
Posts: 2
I keep getting this error

INFO: org.springframework.orm.hibernate.HibernateQueryException: undefined alias: fileN [SELECT fileN,workItemTyC,workItemSbtyC,accN,usTaxIdN,orgId,orgNm,creD,lstEvtD,archD,workDesc,nysePrblC,nysePrdC,fstNm,lstNm,xmlXSz,tsfString FROM com.fmr.xtrac.hibernate.TTkawArchWorkItem WHERE orgId = ? AND workItemSbtyC = 'DUSA']; nested exception is net.sf.hibernate.QueryException: undefined alias: fileN [SELECT fileN,workItemTyC,workItemSbtyC,accN,usTaxIdN,orgId,orgNm,creD,lstEvtD,archD,workDesc,nysePrblC,nysePrdC,fstNm,lstNm,xmlXSz,tsfString FROM com.fmr.xtrac.hibernate.TTkawArchWorkItem WHERE orgId = ? AND workItemSbtyC = 'DUSA']

Here is the code I am using


List WorkItemSearchResultList =
_hibernateTemplate.find(
"SELECT fileN,"
+ "workItemTyC,"
+ "workItemSbtyC,"
+ "accN,"
+ "usTaxIdN,"
+ "orgId,"
+ "orgNm,"
+ "creD,"
+ "lstEvtD,"
+ "archD,"
+ "workDesc,"
+ "nysePrblC,"
+ "nysePrdC,"
+ "fstNm,"
+ "lstNm,"
+ "xmlXSz,"
+ "tsfString"
+ " FROM com.fmr.xtrac.hibernate.TTkawArchWorkItem "
+ "WHERE orgId = ?" + createSearchWhereClause(srchCriteria),
new Object[] {new BigDecimal(cookie.getOrgId())},
new Type[] {Hibernate.BIG_DECIMAL });


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 12:14 am 
Beginner
Beginner

Joined: Mon Jun 13, 2005 5:52 pm
Posts: 43
Please read http://www.hibernate.org/hib_docs/v3/re ... hql-select

You need to alias the class you're selecting from. Instead of:

Code:
select name from User


you need to be aliasing the class, and then referring back to it in the column:

Code:
select user.name from User user


(Should work, AFAIK)

I'm not really seeing why you need to even specify the select portion, anyway. Just using:

Code:
FROM com.fmr.xtrac.hibernate.TTkawArchWorkItem WHERE whatever
should suffice.

I would highly suggest looking at the Criteria API--especially since you appear to be building the where clause on-the-fly.

http://www.hibernate.org/hib_docs/v3/re ... teria.html


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.