-->
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: Query properly generated but I get syntax error in my test
PostPosted: Tue Feb 17, 2009 9:55 am 
Newbie

Joined: Tue Feb 17, 2009 9:35 am
Posts: 1
Hi

Im using hibernate and spring to connect to oracle 10g, the driver im using is ojdbc6.jar I have tested ojdbc5.jar too

Im testing this dao

package test.acw.dao.hibernate;

import java.sql.SQLException;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import my.test.dao.TestDao;
import my.test.dao.search.GenericSearchResult;
import my.test.dao.search.SearchArgumentSupport;
import my.test.domain.Test;
import my.test.domain.dto.TestDto;

public class TestDaoImpl extends HibernateDaoSupport implements TestDao {

@Autowired
@Qualifier("mytest")
protected SessionFactory sessionFactory;

private int pageSize = 20;


@SuppressWarnings("unchecked")
public GenericSearchResult<Claim> search(final SearchArgumentSupport<ClaimDto> a) {

return (GenericSearchResult<Claim>) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query;
GenericSearchResult<Claim> result = new GenericSearchResult<Claim>();
query = session.createQuery("from Test");// where awb=:var1
//query.setString("var1", a.getDto().getAwb());
query.setFirstResult(a.getFirstResult());
query.setMaxResults(a.getMaxResults());
result.setResults(query.list());
query = session.createQuery(
"select count(*) from Test");
//query.setString("s", a.getS());
result.setTotalResults((Long) query.uniqueResult());
return result;
}
});

}

public int getPageSize() {
return pageSize;
}

public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}

}

The query is properly generated (it runs in sqlplus) but when I run the test I get this error:

Hibernate: select * from ( select row_.*, rownum rownum_ from ( select test0_.INCIDENT_NO as INCIDENT1_9_, test0_.INVOICE_NO as INVOICE2_9_, test0_.SHIP_DATE as SHIP3_9_, test0_.test_DATE as test4_9_, test0_.CONTACT_NAME as CONTACT5_9_, test0_.test_SUMMARY as test6_9_, test0_.STATUS as STATUS9_, test0_.CONSIGNEE as CONSIGNEE9_ from vw_web_test_listing test0_ ) row_ ) where rownum_ <= ? and rownum_ > 0
2009-02-17 08:06:26,078 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 156, SQLState: S1000>
2009-02-17 08:06:26,093 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Incorrect syntax near the keyword 'where'.>
2009-02-17 08:06:26,328 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Warning: 156, SQLState: S1000>
2009-02-17 08:06:26,328 WARN [org.hibernate.util.JDBCExceptionReporter] - <Preparing the statement failed: Incorrect syntax near the keyword 'where'.>


Thanks & Regards,
Johnny


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.