This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes NamedParameterJdbcTemplate and Function Call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "NamedParameterJdbcTemplate and Function Call" Watch "NamedParameterJdbcTemplate and Function Call" New topic
Author

NamedParameterJdbcTemplate and Function Call

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Hey guys,

I am facing a little problem, which I think is owing to the underlying prepared statement of the jdbc template.

here is what i want to do.



The tricky part is the location, which is a longitude latitude pair which must be interpreted as a postgis geometry.

what the underlying implementation of params.addValue("location", bookingCreditTour.getLocation()) does is the following:




So the addValue method turns the LocationDV into a String ST_MakePoint(longitude, latitude).

Of course, the ST_MakePoint is a postgis function that needs to be evaluated on the db-server, and i think this is where the problem lies, as this does not go together with prepared statements (or at least i don't know how to).

I could turn the sql query into



but I would really like to encapsulate this away (especially as longitude and latitude tend to get mixed up).

In essence, the question is if there is a way to include this ST_MakePoint function call into the prepared statement.


Thanks for your help


JDBCSupport - An easy to use, light-weight JDBC framework -
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NamedParameterJdbcTemplate and Function Call
 
Similar Threads
variables one class accessed through another class???????
what is the differnet latitudeE6 and latitude
Servlet can't get the xmlhttp post request
Having issues reRendering a map when a rich:tree node is clicked on(SOLVED)
Synchronization