Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: Hibernate 2
here are the string literals that i am using to generate my query
public static String GET_AVAILABLE_CTN_NUMBERS_FROM = "from CTNAvailable cTNAvl ";
public static String GET_AVAILABLE_CTN_NUMBERS_STATUS_AVAILABLE = "where cTNAvl.status=:status1 ";
public static String GET_AVAILBLE_CTN_NUMBERS_STATUS_PICKED = "or cTNAvl.status=:status2 ";
public static String GET_AVAILABLE_CTN_NUMBERS_TIMESTAMP = "and :currentTimeStamp > cTNAvl.timeStamp + interval '30' minute";
and here is the code that i am using
String queryString = HibernateQL.GET_AVAILABLE_CTN_NUMBERS_FROM +
HibernateQL.GET_AVAILABLE_CTN_NUMBERS_STATUS_AVAILABLE +
HibernateQL.GET_AVAILBLE_CTN_NUMBERS_STATUS_PICKED +
HibernateQL.GET_AVAILABLE_CTN_NUMBERS_TIMESTAMP;
// creating the query
query = session.createQuery(queryString);
//setting the query parameters
query.setInteger("status1", 1);
query.setLong("status2", 2);
query.setLockMode("cTNAvl", LockMode.UPGRADE);
query.setParameter ("currentTimeStamp", currentTimestamp);
resultList = query.list();
this is the query that hibernate is generating
Hibernate: select * from ( select ctnavailab0_.CTN_ID as CTN_ID, ctnavailab0_.VE
RSION as VERSION, ctnavailab0_.ALLOCATION_TIME_STAMP as ALLOCATI3_, ctnavailab0_
.PRICE as PRICE, ctnavailab0_.STATUS_ID as STATUS_ID, ctnavailab0_.CTN_NUMBER as
CTN_NUMBER, ctnavailab0_.CREATION_TIME as CREATION7_, ctnavailab0_.CTN_TRACKER_
ID as CTN_TRAC8_ from WRP_CHKOUT_CTN_POOL ctnavailab0_ where (ctnavailab0_.STATU
S_ID=? )or(ctnavailab0_.STATUS_ID=? )and(?>ctnavailab0_.ALLOCATION_TIME_STAMP+in
terval '30' minute ) for update ) where rownum <= ?
and this is the error that it is throwing
[2005-04-05 21:27:36,864] [ExecuteThread: '11' for queue: 'default'] WARN (hibe
rnate.util.JDBCExceptionReporter) - SQL Error: 907, SQLState: 42000
[2005-04-05 21:27:36,864] [ExecuteThread: '11' for queue: 'default'] ERROR (hibe
rnate.util.JDBCExceptionReporter) - ORA-00907: missing right parenthesis
[2005-04-05 21:27:36,880] [ExecuteThread: '11' for queue: 'default'] WARN (hibe
rnate.util.JDBCExceptionReporter) - SQL Error: 907, SQLState: 42000
[2005-04-05 21:27:36,880] [ExecuteThread: '11' for queue: 'default'] ERROR (hibe
rnate.util.JDBCExceptionReporter) - ORA-00907: missing right parenthesis
If we see the query the parenthesis after the "for update" should come before it for the query to work
If anyone has faced this problem please let me know a way out.
Thanks and Regards,
Abhinav