• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in EJB QL Finder Method.....

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am developing an application based on EJB CMP2.0 Spec. I have a CMP BEAN with finder method as follows:-
=================================================================
SELECT Object(b) FROM CartMaster as b where b.customerid = ?1 and b.status='active' and b.cartdate < CURRENT_TIMESTAMP(0)-interval '48 hours'
=================================================================

I am using JBOSS4.0.3. But when I amdeploying bean over Server it gives me error like:-
====================================================================
11:16:23,156 INFO [STDOUT] org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "CURRENT_TIMESTAMP" at line 1, column 102.
Was expecting one of:
<DATETIME_VALUED_PARAMETER> ...
<DATETIME_VALUED_PATH> ...
====================================================================

What is wrong in above Query? How to correct it?

Please help me.

Thanx,
Prash
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody knowing answer to above problem???
Trying it since last 2 days.
Now got frustrated. Please tell me if u know answer.

Please reply anybody.

Thanx in advance.
Prash
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prash,

Where does this section of the query come from ? What is CURRENT_TIMESTAMP?

CURRENT_TIMESTAMP(0)-interval '48 hours'

Chris
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,

Thanx for ur attention towards my problem.

Regarding "CURRENT_TIMESTAMP", I have heard thet its keyword in EJBQL for getting Current Time in java.sql.Timestamp format. In above case, My database have a field with type "timestamp". I am using postgresql8.0 database.

Is it true that EJB2.0 have CURRENT_TIMESTAMP keyword? If not then how should I solve above finder method query?
Also in SQL "CURRENT_TIMESTAMP(0)-interval '48 hours'" this returns the timestamp value with 48 hours less than current timestamp value.

Thanx.
Pls reply.

Prash
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also when I replaced my aboe Query with
====================================
query ="SELECT Object(b) FROM CartMaster as b where b.customerid = ?1 and b.status='active' and b.cartdate = current_time()"
=======================================

Then also I am getting same error.
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont remember seeing CURRENT_TIMESTAMP as a EJB-QL keyword - not saying that it isn't though, I just can't remember.

The way I read your error message it looks like the app server does not expect/accept CURRENT_TIMESTAMP as a valid keyword - Check the EJB spec to confirm that.

Why dont you pass the time stamp through as a parameter to the query in the same way as you are doing with the customer id ? You can then also do your time manipulations outside of the query (makes it easier for me to understand and read).




Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!