]
Nelson Hernández commented on HHH-7216:
---------------------------------------
Same problem here!... any suggestion will be welcome.
"java.lang.IllegalStateException: No supertype found"
thrown on query with "COUNT" aggregate function
-----------------------------------------------------------------------------------------------------
Key: HHH-7216
URL:
https://hibernate.onjira.com/browse/HHH-7216
Project: Hibernate ORM
Issue Type: Bug
Components: core, entity-manager, query-criteria
Affects Versions: 4.1.1
Reporter: Tomas Milo
Priority: Critical
Labels: criteria, jpa2, query
I have 2 entities:
{code}
@Entity
public class Transaction
{
@Id
@Column
private Integer trId;
...
}
{code}
{code}
@Entity
public class Form
{
@Id
@OneToOne
@JoinColumn( name = "trId" )
private Transaction transaction;
@Column
private String firstname;
...
}
{code}
And query:
{code}
private EntityManager em;
...
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> c = cb.createQuery( Long.class );
Root<Form> form = c.from( Form.class );
c.select( cb.count( form ) );
TypedQuery<Long> q = em.createQuery( c );
int count = q.getResultList().get( 0 ).intValue();
{code}
Following exception was thrown on execution of "TypedQuery<Long> q =
em.createQuery( c );":
Caused by: java.lang.IllegalStateException: No supertype found
at
org.hibernate.ejb.metamodel.AbstractIdentifiableType.requireSupertype(AbstractIdentifiableType.java:85)
at
org.hibernate.ejb.metamodel.AbstractIdentifiableType.getIdType(AbstractIdentifiableType.java:173)
at
org.hibernate.ejb.criteria.expression.function.AggregationFunction$COUNT.renderArguments(AggregationFunction.java:110)
at
org.hibernate.ejb.criteria.expression.function.ParameterizedFunctionExpression.render(ParameterizedFunctionExpression.java:94)
at
org.hibernate.ejb.criteria.expression.function.BasicFunctionExpression.renderProjection(BasicFunctionExpression.java:71)
at org.hibernate.ejb.criteria.QueryStructure.render(QueryStructure.java:250)
at org.hibernate.ejb.criteria.CriteriaQueryImpl.render(CriteriaQueryImpl.java:338)
at
org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:216)
at
org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:623)
I think the problem is in the
org.hibernate.ejb.metamodel.AbstractIdentifiableType.getIdType() function, which is not
prepared for "mapped identifier" (as is
org.hibernate.ejb.metamodel.MetadataContext.applyIdMetadata procedure).
--
This message is automatically generated by JIRA.
For more information on JIRA, see: