On a web UI, lets say the user can fill in values into fields to perform searching on items. (color, size, style..etc)
After filling in the form, the user will then hit the search button to get the list of items that fits the search criteria.
Now, lets say the user wants to save that search, so he/she can execute it later on. ie label it as.. "summer clothes I want", so any time they want to they can click on that link and it will return the results they previously searched upon. Now there can be two types of saving, the query itself, or the results it brings back.. but i'll not address that here.
Question is: from the search form, I could create a sql string by hand (HQL) like "FROM classpath.Clothes clothes where clothes.color = 'red' ..blah blah.. and then save this to the database. But this would require me to check for apostrophes in the strings, and format dates to a certain sql way.
Or, using a detached criteria, and building it from the form. Is there a way to save that criteria to the database? possibly serialize the object and save it as a blob? If this can be done, how about in Hibernate 4.0.. the seralization of the criteria can use a different serial id causing exceptions. I also searched and wondered if there was a way to extract the sql out of a detached criteria, so it can be saved for later us.
Hope this makes some sense.
Thoughts?
|