Hi Julien
The problem is the fact that you're using a raw type to store the
intermediate query construction step:
> SelectConditionStep query =
context.select(...).from(...).where(...).and(...).and(...);
As you may have noticed, SelectOrderByStep has a generic parameter <R
extends Record>, like many of jOOQ's types. You usually have a couple of
options then:
1. Use the most specific, appropriate type, e.g.
SelectConditionStep<Record3<Integer, String, Long>> query = ...
2. Use a wildcard, e.g. any of these two equivalent ones:
SelectConditionStep<? extends Record> query = ...
SelectConditionStep<?> query = ...
3. Use a raw type and suppress all warnings. This should usually be your
last option. e.g.
SelectConditionStep query
In your case, you can probably live with using a wildcard "?" as a generic
type parameter when assigning the object to a local variable.
For more information, I suggest reading up a couple of tutorials about Java
and generics, as jOOQ 3.0 makes heavy use of them. An good tutorial is this
one:
http://docs.oracle.com/javase/tutorial/java/generics
Hope this helps.
Lukas
2013/5/15 Julien GILLES <[email protected]>
> Hello
>
> I am a new user of Jooq - a not yet very comfortable with Java - so sorry
> if the answer is in a tutorial or in the documentation, but I can't find
> it...
>
> I have a classic request :
>
> List<Foo> foos =
> context.select(...).from(...).where(...).and(...).and(...).fetchInto(Foo.class);
>
> it works fine.
>
>
> I want to add an orderBy only if necessary, so I tried something like :
>
> SelectConditionStep query =
> context.select(...).from(...).where(...).and(...).and(...);
>
> if (...) {
> foos = query.orderBy(Table.Column.sort(dir)).fetchInto(Foo.class)
> }
>
> But I have warning : " unchecked call to orderBy(org.jooq.SortField<?>...)
> as a member of the raw type org.jooq.SelectOrderByStep
>
> Should I use @java.lang.suppressWarnings({ "unchecked" }), or is there a
> better way to achieve this ?
>
>
> --
> Julien Gilles.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.