[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-3222) named query string manipulation

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Mon Apr 7 13:19:33 EDT 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Rydahl Andersen closed HHH-3222.
------------------------------------

    Resolution: Won't Fix

per users request.

> named query string manipulation
> -------------------------------
>
>                 Key: HHH-3222
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3222
>             Project: Hibernate3
>          Issue Type: New Feature
>            Reporter: Szczepan Faber
>
> I'd like to manipulate query string that lives in named query (xml file).
> Java does not support multiline Strings - In order to keep queries readable we use named queries that live in xml files. Sometimes those queries are nearly the same (single table name is different, etc). We would like to avoid keeping two instances of nearly the same queries to avoid duplication of sql, tests and minimize bugs.
> Here is an example from our application (2 years/30 devs). We have a concept of draft and live, e.g theoretical PAGE table spans into LIVE_PAGE and DRAFT_PAGE (and for many reasons we cannot change this pattern). We have many complex queries (complex joins, etc.) that are identical with one little difference: one joins to DRAFT table, the other one to LIVE table.
> The interface I was thinking about is (just an example):
> sessionFactory.getCurrentSession().getNamedQuery("foo", *QueryTransformer*)
> interface QueryTransformer {
>     String transform(String query);
> }
> Then, we could write our named queries like that:
> <sql-query name="foo">
>     ...
>     join {draftOrLive}_PAGE on ...
>     ...
> and implement our own QueryTransformer that would resolve table name properly to LIVE_PAGE or DRAFT_PAGE
> Can you please give me some feedback on that feature? Probably we will implement it anyway but if you see some gotchas/issues with the idea then please let me know.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list