[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5301?page=c...
]
Gail Badner commented on HHH-5301:
----------------------------------
Section 4.6.17.4 says:
"The Java class of the entity is used as an input parameter to specify the entity
type".
Are you getting the exception when you bind the Java class (i.e, not the entity name
literal)?
If so, please do the following:
* checkout the trunk version
http://anonsvn.jboss.org/repos/hibernate/core/trunk
* add a test that reproduces your issue to
entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java;
* create a patch using "svn diff" and attach to this issue
Thanks,
Gail
Add support for parametrizing TYPE(e) expressions
-------------------------------------------------
Key: HHH-5301
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5301
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2, Java 6.0.20
Reporter: Luis Fernando Planella Gonzalez
Support parameters for JPA 2's TYPE(alias) function.
Test classes:
@Entity
@DiscriminatorColumn(name="subclass")
@Table(name="xs")
public abstract class XBase {
@Id
private Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
@Entity
@DiscriminatorValue("x1")
public class X1 extends XBase {
@Basic
private String x1;
public String getX1() {
return x1;
}
public void setX1(String x1) {
this.x1 = x1;
}
}
@Entity
@DiscriminatorValue("x2")
public class X2 extends XBase {
@Basic
private String x2;
public String getX2() {
return x2;
}
public void setX2(String x2) {
this.x2 = x2;
}
}
Running the following query works: "select x from XBase x where type(x) = X1"
However, the following one: "select x from XBase x where type(x) = :t" yelds
Exception in thread "main" java.lang.UnsupportedOperationException: At the
moment this type is not the one actually used to map the discriminator.
at
org.hibernate.persister.entity.DiscriminatorType.nullSafeSet(DiscriminatorType.java:111)
at
org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:567)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1612)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
at org.hibernate.loader.Loader.list(Loader.java:2167)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:448)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:241)
at test.Main.main(Main.java:28)
JPA 2's spec explicitly shows querying by type using parameters in section 4.6.17.4.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira