[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-1369) Restrictions.eq In Criteria Not matching a property of type java.lang.Class
David CLEMENT (JIRA)
noreply at atlassian.com
Fri Apr 6 08:58:04 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David CLEMENT updated HHH-1369:
-------------------------------
Attachment: criteriaclass.zip
test case for the problem
> Restrictions.eq In Criteria Not matching a property of type java.lang.Class
> ---------------------------------------------------------------------------
>
> Key: HHH-1369
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1369
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.1
> Environment: HB 3.1, Hibernate annotations 3.1-beta-7, Postgres 8.0.3
> Reporter: Matt Todd
> Attachments: criteriaclass.zip
>
>
> When using criteria query to get an entity using the following method:
> session.createCriteria(Vocabulary.class).add(Restrictions.eq("klass", MethodOfContact.class)).uniqueResult()
> No results are returned. Using an alternative method:
> session.createCriteria(Vocabulary.class).add(Restrictions.in("klass", new Object[] {MethodOfContact.class})).uniqueResult()
> returns the correct result.
> The annotations on the mapped class are:
> @Column(unique=true, nullable = false)
> private Class klass;
> The error is possibly comming from here looking at the debug:
> 15:50:55,479 DEBUG SQL:346 - /* criteria query */ select this_.id as id1_1_, this_.default_value as default5_1_1_, this_.name as name1_1_, this_.klass as klass1_1_, this_.type as type1_1_, vocabulary2_.id as id0_0_, vocabulary2_.available as available0_0_, vocabulary2_.value as value0_0_, vocabulary2_.type as type0_0_ from vocabulary this_ left outer join vocabulary_value vocabulary2_ on this_.default_value=vocabulary2_.id where this_.klass=?
> Hibernate: /* criteria query */ select this_.id as id1_1_, this_.default_value as default5_1_1_, this_.name as name1_1_, this_.klass as klass1_1_, this_.type as type1_1_, vocabulary2_.id as id0_0_, vocabulary2_.available as available0_0_, vocabulary2_.value as value0_0_, vocabulary2_.type as type0_0_ from vocabulary this_ left outer join vocabulary_value vocabulary2_ on this_.default_value=vocabulary2_.id where this_.klass=?
> 15:50:55,481 DEBUG AbstractBatcher:424 - preparing statement
> 15:50:55,495 DEBUG GooGooStatementCache:381 - cxnStmtMgr.statementSet( org.postgresql.jdbc3.Jdbc3Connection at 650892 ).size(): 1
> 15:50:55,500 DEBUG GooGooStatementCache:117 - checkoutStatement:
> com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 1; checked out: 1; num connections: 1; num keys: 1
> 15:50:55,511 DEBUG StringType:79 - binding ''uk.co.iizuka.advice.MethodOfContact'' to parameter: 1
> The last debug line seems a possibility for the error as the binding classname has double quotes around it. When using the "Restrictions.in" method, there are only single quotes.
--
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