[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-746) Criteria query on "class" property

Andrew Ebaugh (JIRA) noreply at atlassian.com
Wed Aug 1 14:45:11 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27693 ] 

Andrew Ebaugh commented on HHH-746:
-----------------------------------

In what version was this fixed? I'm using 3.2.0ga and I still see an issue with making Criteria queries referencing an associated property type.

When I create Criterion like so:
Expression.eq("associatedproperty.class", MySublcassProperty.class)

it's close, but does not work the same as a HQL query with "... where associatedproperty.class = MySubclassProperty"

In this example, the discriminator value for the entity MySubclassProperty is MP. The call to getDiscriminatorSQLValue() in CriteriaQueryTranslator.getTypedValue returns 'MP', which ends up in the resultant SQL query as '\'MP\'', i.e. with the apostrophes escaped within another set of apostrophes.

I wrote a workaround that is not particularly pretty, but will strip off the leading/trailing apostrophes. It can be used as follows, in place of the Expression.eq call above:
new TypeEqualityExpression("associatedproperty.class", MySublcassProperty.class)

> Criteria query on "class" property
> ----------------------------------
>
>                 Key: HHH-746
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-746
>             Project: Hibernate3
>          Issue Type: Improvement
>          Components: core
>         Environment: 3.06, Oracle
>            Reporter: Cuong Tran
>            Assignee: Joshua Davis
>            Priority: Minor
>          Time Spent: 1 hour
>  Remaining Estimate: 0 minutes
>
> Currently, when using the "class" property on Criteria query, hibernate doesn't translate the value into the underlying discriminator.  See the discussion/test case here:
> http://opensource.atlassian.com/projects/hibernate/secure/CreateIssue.jspa

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