Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-15782

[GSS](7.2.z) HHH-13084: Querying entity with non-ID property named 'id' fails if entity has an IdClass composite key

    XMLWordPrintable

    Details

    • Target Release:
    • Steps to Reproduce:
      Hide
      @Entity(name = "Person")
      @IdClass(PersonId.class)
      public static class Person implements Serializable {
          @Id
          private String name;
      
          @Id
          @Column( name = "ind")
          private int index;
          private Integer id;
      }
      

      Executing the following query results in a NullPointerException:

      s.createQuery( "from Person p where p.id is null", Person.class ).list()

      Show
      @Entity(name = "Person" ) @IdClass(PersonId.class) public static class Person implements Serializable { @Id private String name; @Id @Column( name = "ind" ) private int index; private Integer id; } Executing the following query results in a NullPointerException: s.createQuery( "from Person p where p.id is null", Person.class ).list()

      Description

      Query failure with exception like:

      org.hibernate.QueryException: could not resolve property: null of: org.test.entities.Person
      	at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:73)
      	at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:88)
      	at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:43)
      	at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1952)
      	at org.hibernate.hql.internal.ast.tree.FromElementType.toColumns(FromElementType.java:442)
      	at org.hibernate.hql.internal.ast.tree.FromElementType.toColumns(FromElementType.java:408)
      	at org.hibernate.hql.internal.ast.tree.FromElement.toColumns(FromElement.java:513)
      	at org.hibernate.hql.internal.ast.tree.FromElement.getIdentityColumns(FromElement.java:344)
      	at org.hibernate.hql.internal.ast.tree.IdentNode.resolveAsAlias(IdentNode.java:198)
      	at org.hibernate.hql.internal.ast.tree.IdentNode.resolve(IdentNode.java:124)
      	at org.hibernate.hql.internal.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:1045)
      	at org.hibernate.hql.internal.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:1033)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:5080)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExprLhs(HqlSqlBaseWalker.java:5614)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4987)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1286)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4706)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4174)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2138)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:815)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:609)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313)
      	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:271)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191)
      	...
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gbadner Gail Badner
              Reporter:
              stephen.fikes Stephen Fikes
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: