[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5878) Add ability to mark keywords as protected dynamically to prevent table aliasing when using @Formula

Ian Simpson (JIRA) noreply at atlassian.com
Thu Jan 27 17:09:05 EST 2011


Add ability to mark keywords as protected dynamically to prevent table aliasing when using @Formula
---------------------------------------------------------------------------------------------------

                 Key: HHH-5878
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5878
             Project: Hibernate Core
          Issue Type: New Feature
          Components: annotations, core
    Affects Versions: 3.2.5
         Environment: 3.2.5.ga/Oracle 11g database
            Reporter: Ian Simpson


Using the following in a @Formula does not work due to keywords being aliased to the entity the formula is part of:

{code}
@Formula("(select count(1) from sometable st " +
    "where st.othertable_id in ( " +
      "select distinct id from othertable ot " +
      "start with ot.id = id " +
      "connect by nocycle prior ot.id = ot.parent_id " +
    "))"
  )
{code}

The end result is:
{code}
(SELECT COUNT(1)
  FROM sometable st
  AND st.othertable_id IN
    ( SELECT DISTINCT otherta0_.id
    FROM othertable ot otherta0_.start otherta0_.with cc.id = otherta0_.id otherta0_.connect BY otherta0_.nocycle otherta0_.prior cc.id = cc.parent_id
    )
  )
{code}

What (I think) might be preferable is being able to indicate that certain parts are keywords and that they shouldn't be aliased.  The inverse is already doable by adding backticks to a field/table/whatever that does match a protected keyword.  For example:
{code}
@Formula("(select count(1) from sometable st " +
    "where st.othertable_id in ( " +
      "select distinct id from othertable ot " +
      "!!start !!with ot.id = id " +
      "!!connect by nocycle !!prior ot.id = ot.parent_id " +
    "))"
  )
{code}

... or something of that nature which Hibernate can seek out a know to process differently.  I have no idea if "!!" would be usable, but I think you get what I'm saying.

-- 
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