-->
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: Problem with CURRENT_TIMESTAMP in where attribute of <set
PostPosted: Wed Mar 28, 2007 5:48 am 
Newbie

Joined: Wed Mar 28, 2007 5:16 am
Posts: 1
Summary:
I am using a <set> collection with a custom where clause:
Code:
   
<set name="filterRules" table="Filter_Rules" where="start_tms &lt; SYSDATE">
    ...
</set>

which is working fine on Oracle (Oracle9Dialect). During porting to a different DBMS I tried to change this to use CURRENT_TIMESTAMP instead:
Code:
         where="start_tms &lt; CURRENT_TIMESTAMP"

The generated SQL statement with SYSDATE is:
Code:
... and filterrule0_.start_tms < SYSDATE ...

which is correct, but when I use CURRENT_TIMESTAMP I get:
Code:
... and filterrule0_.start_tms < filterrule0_.CURRENT_TIMESTAMP ...

The problem is that the keyword CURRENT_TIMESTAMP is not listed as keyword in the class Oracle9Dialect like SYSDATE.

Suggested Resolution: I think the following keywords should be added as registered Functions to the Oracle9Dialect:
CURRENT_TIMESTAMP
CURRENT_DATE

Hibernate version: Hibernate 2.1.8

Full stack trace of any exception that occurs:
Code:
2007-03-28 11:41:47,673 [main] DEBUG - select filterrule0_.PRNT_FLST_OID as PRNT_FLS2___, filterrule0_.FLSP_OID as FLSP_OID__, filterrule0_.FLSP_OID as FLSP_OID2_, filterrule0_.PRNT_FLST_OID as PRNT_FLS2_2_, filterrule0_.START_TMS as START_TMS2_, filterrule0_.END_TMS as END_TMS2_, filterrule0_.FLST_OID as FLST_OID2_, filterrule0_.FLRD_OID as FLRD_OID2_, filterrule0_.COND_AND_OR_IND as COND_AND7_2_, filterrule1_.FLST_OID as FLST_OID0_, filterrule1_.START_TMS as START_TMS0_, filterrule1_.END_TMS as END_TMS0_, filterrule1_.FILTER_RULE_SET_NME as FILTER_R4_0_, filterrule2_.FLRD_OID as FLRD_OID1_, filterrule2_.TBL_ID as TBL_ID1_, filterrule2_.COL_NME as COL_NME1_, filterrule2_.OPERATOR_CDE as OPERATOR4_1_, filterrule2_.FILTER_VAL_TXT as FILTER_V5_1_, filterrule2_.FILTER_RULE_TXT as FILTER_R6_1_, filterrule2_.FILTER_VAL_TYP as FILTER_V7_1_, filterrule2_.JOIN_TBL_ID as JOIN_TBL8_1_, filterrule2_.JOIN_COL_NME as JOIN_COL9_1_, filterrule2_.START_TMS as START_TMS1_, filterrule2_.END_TMS as END_TMS1_, filterrule2_.FILTER_RULE_NME as FILTER_12_1_ from FT_T_FLSP filterrule0_ left outer join FT_T_FLST filterrule1_ on filterrule0_.FLST_OID=filterrule1_.FLST_OID left outer join FT_T_FLRD filterrule2_ on filterrule0_.FLRD_OID=filterrule2_.FLRD_OID where filterrule0_.PRNT_FLST_OID=? and filterrule0_.start_tms < filterrule0_.CURRENT_TIMESTAMP and (filterrule0_.end_tms is null or filterrule0_.end_tms >= SYSDATE) order by filterrule0_.RULE_SQ_NUM asc
2007-03-28 11:41:47,689 [main] DEBUG - preparing statement
2007-03-28 11:41:47,720 [main] DEBUG - SQL Exception
java.sql.SQLException: ORA-00904: "FILTERRULE0_"."CURRENT_TIMESTAMP": invalid identifier

   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
   at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:744)
   at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
   at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:809)
   at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
   at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:849)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
   at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3338)
   at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3383)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:1020)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:995)
   at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
   at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:288)
   at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3315)
   at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
   at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3168)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:143)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1531)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1527)
   at ftisoft.StreetEnterprise.service.publish.commands.SecuritiesFilter.getFilterRuleset(SecuritiesFilter.java:380)
   at ftisoft.StreetEnterprise.service.publish.commands.SecuritiesFilter.process(SecuritiesFilter.java:103)
   at ftisoft.StreetEnterprise.service.publish.commands.test.TestSecuritiesFilter.runTestCase(TestSecuritiesFilter.java:380)
   at ftisoft.StreetEnterprise.service.publish.commands.test.TestSecuritiesFilter.testCustomWhereClause(TestSecuritiesFilter.java:201)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
2007-03-28 11:41:47,736 [main] WARN  - SQL Error: 904, SQLState: 42000
2007-03-28 11:41:47,751 [main] ERROR - ORA-00904: "FILTERRULE0_"."CURRENT_TIMESTAMP": invalid identifier


Name and version of the database you are using:Oracle 10.2.

The generated SQL (show_sql=true):see above in stack trace


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.