Hi. See the work-around lower:
> sorry miss send previuos message
>
> Hi all
>
> what write this select to JAWS?
>
> select max(col1) ... where col2="xxx"
>
> I try:
> <finder>
> <name>findByMaxCol</name>
> <query>MAX(col1) WHERE col2 = {0}</query>
FIRST: the above equals to: "select * from THE_TABLE WHERE MAX(col1) WHERE
col2 = {0}"
Dumb uh?
SECOND: A finder method has to return FULL ROW! One value only is not
sufficient.
The query you want I think is: "select max(col1) where col2 = {0}" right?
This can't be enough, for the entity to load. See?
> <order></order>
> </finder>
>
> but don't working, can any help me?
>
> Miro
SOLUTION: to get the max(col1) where col2 = {0} use the following:
<finder>
<name>findByMaxCol</name>
<query>col2={0} and col1= (select max(col1) from the_table where
col2={0})</query>
<order />
</finder>
Prerequisites: The DB has to be able to run such subselects in the where
clause (Most new do).
WARNING!: Hypersonic does NOT do that. I have touched the HSqlDB
developers, but they refuse to do that.
Then using findByMaxCol(ValueOfCol2).getCol1() will give you the required
value.
Explanation: This returns a row (or more!), that will contain:
A) Col2 will be equal to {0}.
B) Col1 will be equal to the maximum col1, where the col2 is {0}
See? The retreiving the col1 value of this entity will return the needed
one.
Cheers.
May the shade of the tree strengthen you.
Lachezar Dobrev.
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user