[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2828) criteria search by class throws org.hibernate.QueryException: Unsupported discriminator type null when mapping exists for this class

Josh Channings (JIRA) noreply at atlassian.com
Thu May 17 10:27:09 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-2828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46680#comment-46680 ] 

Josh Channings commented on HHH-2828:
-------------------------------------

This issue is still present in v3.6.10 (via Grails 2.0.3)

> criteria search by class throws org.hibernate.QueryException: Unsupported discriminator type null  when mapping exists for this class
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-2828
>                 URL: https://hibernate.onjira.com/browse/HHH-2828
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.5
>         Environment: hibernate 3.2.5, oracle 10g
>            Reporter: jo desmet
>         Attachments: src.zip
>
>
> when making a criteria based on a property of type class the query succeeds if this class is not mapped, the query building fails when this class is mapped within hibernate and has no discriminator
> e.g. code :
>                 Criteria l = session.createCriteria(SearchClass.class);
>                 l.add(Restrictions.eq("type", ClassWithNoMapping.class));  // SUCCESS
>                 java.util.List result = l.list();
>                 l = session.createCriteria(SearchClass.class);
>                 l.add(Restrictions.eq("type", ClassWithMapping.class));   // EXCEPTION
>                 result = l.list();
> exception is 
> Hibernate: select this_.ID as ID0_0_, this_.name as name0_0_, this_.type as type0_0_ from SEARCHCLASS this_ where this_.type=?
> org.hibernate.QueryException: Unsupported discriminator type null
> 	at org.hibernate.loader.criteria.CriteriaQueryTranslator.getTypedValue(CriteriaQueryTranslator.java:499)
> 	at org.hibernate.criterion.SimpleExpression.getTypedValues(SimpleExpression.java:71)
> 	at org.hibernate.loader.criteria.CriteriaQueryTranslator.getQueryParameters(CriteriaQueryTranslator.java:251)
> 	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)
> 	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
> 	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
> 	at Test.list(Test.java:40)
> 	at Test.main(Test.java:27)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> classes are attached, tables should exists but no data is required.
> Please also provide workaround on short term if possible

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list