Uploaded image for project: 'Hibernate ORM'
  1. HHH-7216

"java.lang.IllegalStateException: No supertype found" thrown on query with "COUNT" aggregate function

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      I have 2 entities:

      @Entity
      public class Transaction
      {
      	@Id
      	@Column
      	private Integer trId;
      ...
      }
      
      @Entity
      public class Form
      {
      	@Id
      	@OneToOne
      	@JoinColumn( name = "trId" )
      	private Transaction transaction;
      
      	@Column
      	private String firstname;
      
      ...
      }
      

      And query:

      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();
      

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

        Attachments

          Activity

            People

            • Votes:
              11 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: