I don't -think- you can in Criteria. Probably possible in HQL with a custom
dialect, but the gain would be low.

Since you're not filtering using those custom functions, I would think you
could simply select the data and do the calculation inside a public property
in your entity though... no real need to do it server side. Wouldn't even
change performance much.

-Francois

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of cs
Sent: Saturday, May 07, 2011 7:21 PM
To: nhusers
Subject: [nhusers] rewriting query as ICriteria

I have the following query (PostgreSQL) that I'd like to convert to
ICriteria:

SELECT
  t.theater_id as tid,
  round(cast (sqrt(pow(69.172 * (latitude-:lat(float)),2) +
        pow(50.8750184225293 * (t.longitude-:lng(float)),2)) as
numeric),2)
     as distance
FROM
  theater t

Is it possible to write this query using QueryOver/ICriteria? Or am I better
off projecting this as SQL? Ideally, I'd like for this to work in both
dev/production with developer tests using SQLite and production using
Postgres. Some of the functions I'm using aren't supported on SQLite, which
is causing problems for me.

Thanks!

--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to