Bruce Snyder wrote:
> This one time, at band camp, ODVARKO said:
>
> O>I have tried the LIMIT keyword with MySQL database and I get an exception.
> O>Any Ideas? Thanks for any help.
> O>
> O>String oql =
> O> "SELECT v " +
> O> "FROM <package>.MyClass v " +
> O> "LIMIT $1, $2 ";
> O>
> O>OQLQuery query = db.getOQLQuery(oql);
> O>query.bind(5);
> O>query.bind(10);
> O>
> O>java.lang.ArrayIndexOutOfBoundsException
>
> ArrayIndexOutOfBoundsExceptions are usually thrown because a value
> that was attempted to be fetched is not available. IOW, are you
> sure that there are at least 10 rows available to be fetched?
> ...
There is limitation with LIMIT Clause. LIMIT is handle by SQL and NOT by
OQL ...
So if you have a Class with a one-to-many relation you always have N
Rows in your SQL request but not N Objects in OQL.
With this example.
----- 1 n -----
- a - ----> - b -
----- -----
and in DB Table
------ -----------
- a - - b -
- id - - id id_a -
------ - 1 1 -
- 1 - - 2 1 -
- 2 - - 3 1 -
------ -----------
The following OQL request :
Select p from mypackage.a p LIMIT 2;
become in SQL :
Select a.id, b.id from a,b where a.id=b.id_a LIMIT 2;
So there is two rows :
a.id b.id
1 1
1 2
But one incomplete Object ...
Hope this can help.
--
Florian.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev