sql - Combine NamedQuery and Criteria in Hibernate -
i use hibernate in storefinder application. proximity search in sql use haversine formula. because bit messy sql created named sql query in .hbm.xml file this.
select location.*, ( 3959 * acos( cos( radians(7.4481481) ) * cos( radians( x(location.coordinates) ) ) * cos( radians( y(location.coordinates) ) - radians(46.9479986) ) + sin( radians(7.4481481) ) * sin( radians( x(location.coordinates) ) ) ) ) distance location location.coordinates not null having distance < :radius order distance asc limit :max
but have user defined filter (opening hours, assortments, etc.). use hibernate criteria programatically add filters.
now have working namedquery giving me locations around point , working criteria query giving me locations according filter.
my question is: best way in hibernate combine 2 beasts? (i.e. need locations around point satisfying filter.) there example way use namedquery subquery in criteria search?
what best way in hibernate combine 2 beasts?
to knowledge, that's not possible. either write using criteria query (i don't know how you're asking for) or compute dynamic hql string.
Comments
Post a Comment