-->
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: Newbie: Trying to do aggregate
PostPosted: Fri Jun 03, 2005 4:35 pm 
Newbie

Joined: Fri Jun 03, 2005 4:23 pm
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1

Mapping documents:

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory name="WTPYSessionFactory">
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="connection.url">
xxx
</property>
<property name="hibernate.connection.username">xxx</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.connection.schema">xxx</property>
<property name="dialect">
net.sf.hibernate.dialect.Oracle9Dialect
</property>
<property name="hibernate.show_sql">true</property>
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping resource="Request.hbm" />
<mapping resource="Response.hbm" />
</session-factory>
</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():


public List findSearchResults(String where, Vector pkeys, Vector pvalues) throws HibernateException {

List list = null;
try {
StringBuffer sb = new StringBuffer("select count(*), req.ReqNo, req.Ssn, req.CanBic, req.NameLast, req.NameFirst ");
sb.append(" from WTPYRequest as req where ");
sb.append(where);
sb.append(" group by req.ReqNo, req.Ssn, req.CanBic, req.NameLast, req.NameFirst ");
Session hibernateSession = WTPYHibernateUtil.currentSession();
Query q = hibernateSession.createQuery(sb.toString());

for(int i= 0; i< pkeys.size(); i++)
{
System.out.println("WTPYRequestDAO.findSearchResults setParameter " +
" key " + (String)pkeys.get(i) + " values " + (String)pvalues.get(i));
q.setParameter((String)pkeys.get(i), (String)pvalues.get(i));
}

list = q.setMaxResults(500).list();

} catch (Exception e) {
...
} finally {
WTPYHibernateUtil.closeSession();
}
return list;
}

JSP:

<h:dataTable border="0" cellpadding="2" cellspacing="0"
columnClasses="columnClass1" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1"
styleClass="dataTable" id="table1"
value="#{wTPYSearchBean.searchResults}" var="varresults">


Full stack trace of any exception that occurs:

[6/3/05 15:15:41:275 CDT] 59b297b0 SystemOut O WTPYRequestDAO.findSearchResults threw Exception undefined alias: 1 [select 1 as {req.Id}, req.ReqNo, 1 as {req.ReqLevel}, req.Ssn, req.CanBic, req.NameLast, req.NameFirst from us.tx.state.hhsc.wtpy.WTPYRequest as req where req.CanBic = :CanBic group by req.ReqNo, req.Ssn, req.CanBic, req.NameLast, req.NameFirst ]


Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true): yes

Debug level Hibernate log excerpt:


Help, Help, Help...

Thanks,
Angela


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.