Hello everybody,
I have a problem to make an OQL query, I hope that someone can help me.
PLEASE IT IS REALLY IMPORTANT FOR OUR PROJECT, WITHOUT THIS WE CAN STOP OUR
PROJECT ( +9 month of work currently ) !!
1 - the model
--------------------
I have 2 object :
a. Instrument
b. Quotation
An instrument have severals quotation (aggregation, collection), I use lazy
loading !
2 - the query
------------------
I need to get all the instrument of the database and the associated
quotation with the highest Date.
Questions
---------------
1 - is this query possible ?
2 - if yes, can you help me to create it ?
3 - if no, how can I do (Create severals queries, scan all the quotations
of a instrument ?)
What I do
---------
- I do 2 queries
The first query is :
SELECT i FROM lds.ecm.instrument.Instrument i
The second query :
SELECT q FROM lds.ecm.instrument.Quotation q WHERE q.StockExchangeDate = (
SELECT max( q.StockExchangeDate ) FROM lds.ecm.instrument.Quotation q WHERE
q.Instrument = $1 )
I bind the second query with a resulted Instrument and I have the following
error :
javax.resource.ResourceException: An inapropriate token (1) was encountered
in an expression.
What I have try
----------------
- I have also try to use SQL Direct !!
String tSQL = "CALL SQL SELECT \"FQuotation\".\"PrimaryKey\",
\"FQuotation\".\"InstrumentTC\",\"FQuotation\".\"ProviderCode\",
\"FQuotation\".\"StockExchangeCode\",\"FQuotation\".\"QuoteTypeCode\",
\"FQuotation\".\"StatisticalQuoteTypeCode\",\"FQuotation\".
\"ValueCurrencyCode\",\"FQuotation\".\"Value\",\"FQuotation\".
\"ProviderDate\",\"FQuotation\".\"StockExchangeDate\"";
tSQL += "FROM \"FQuotation\" WHERE (\"FQuotation\".\"InstrumentTC\"
= $1) AND \"FQuotation\".\"StockExchangeDate\" = ( SELECT max(\"FQuotation.
\"StockExchangeDate\") FROM \"FQuotation\"WHERE \"FQuotation\".
\"InstrumentTC\" = $2 ) AS lds.ecm.instrument.Quotation";
I m unable to bind $2 !!!
- I try to use MAX, but without success
- Maybe using the LAST feature of OQL
Thanks a lot for your help
Demez Christophe
Linedata
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev