Hi there,

What database are you using for this?

In principle, I do not see any obstactle to expressing your query with
jOOQ. Note that "PI * x / 180" would be rad(x) in jOOQ:
-
http://www.jooq.org/javadoc/latest/org/jooq/impl/DSL.html#rad(org.jooq.Field)

Now, ACOS() indeed doesn't currently accept Condition arguments. That's an
interesting approach, so you want 0 for true and PI/2 for false? I guess
you will need to resort to using a DECODE() or CASE expression:
- http://www.jooq.org/javadoc/latest/org/jooq/impl/DSL.html#decode()
-
http://www.jooq.org/javadoc/latest/org/jooq/impl/DSL.html#decode(org.jooq.Field,%20org.jooq.Field,%20org.jooq.Field,%20org.jooq.Field..
.)

You can always also resort to plain SQL or to creating custom QueryParts in
jOOQ, if you're missing a feature:
- http://www.jooq.org/doc/latest/manual/sql-building/plain-sql/
-
http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-queryparts/

Hope this helps,
Lukas


2014-05-10 16:24 GMT+02:00 <[email protected]>:

> Hi,
> we are evaluating JOOQ at the moment and one hibernate (well, native sql
> ;P ) query we have is:
>
> Restrictions.sqlRestriction("? * ACOS((SIN(PI() * ? / 180) * SIN(PI() *
> hospital2_.latitude/ 180)) + (COS(PI() * ? /180) * cos(PI() *
> hospital2_.latitude / 180) * COS(PI() * hospital2_.longitude / 180 - PI() *
> ? / 180)) ) <= ?", params, types)
>
> (The 4 parameters you have in this query, are all BigDecimals, or in code
> speak:
> Distance.earthRadius(withDistance.getUnit()).getLength(),
> fromCoordinate.getLatitude(), fromCoordinate.getLatitude(),
> fromCoordinate.getLongitude(), withDistance.getLength()))
>
> I played around with acos() a bit and it seems it cannot take a condition
> as parameter? Or am I going down the wrong path?
>
> Thanks
>
>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to