# Access nested property in properties block in criteria query

**URL:** <https://discourse.hibernate.org/t/access-nested-property-in-properties-block-in-criteria-query/3945>\
**Category:** Hibernate ORM\
**Created:** [March 26, 2020, 4:14pm UTC](https://discourse.hibernate.org/t/access-nested-property-in-properties-block-in-criteria-query/3945 "2020-03-26T16:14:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thmayr](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@thmayr](https://discourse.hibernate.org/u/thmayr)\
**Post date:** [March 26, 2020, 4:14pm UTC](https://discourse.hibernate.org/t/access-nested-property-in-properties-block-in-criteria-query/3945/1 "2020-03-26T16:14:19Z")

</div>

Hello Hibernate Folks,

I have the following _properties_ block in my hibernate mapping:

```auto
    <class name="de.bayernlb.kundenportal.businessclasses.bankaccount.BankAccount"
           table="KP_CREDITACCOUNT">
        <id name="bankAccountId"
            column="CREDITACCOUNTID"
            type="java.lang.Long"
            access="field">
            <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
                <param name="sequence_name">KP_SEQUENCE_BANKACCOUNT</param>
            </generator>
        </id>
        <properties name="bankAccountKey">
            <property name="bankAccountId"
                      type="java.lang.Long"
                      column="CREDITACCOUNTID"
                      insert="false"
                      update="false"/>
            <property name="imported"
                      column="IMPORTED"
                      access="field"
                      insert="true"
                      update="true">
                <type name="de.bayernlb.kundenportal.persistence.HibernateTypeStringToBoolean">
                    <param name="falseValue">0</param>
                    <param name="trueValue">1</param>
                </type>
            </property>
        </properties>
        ...
    </class>

```

The class _BankAccount_ has the attributes _bankAccountId_ and _imported_:

```auto
public abstract class BankAccount implements Comparable, Localizable, Serializable {
    private Long bankAccountId;
    private boolean imported = true;
    ...
}

```

How can I access the _imported_ property in the following criteria. When I try this:

```auto
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
...
criteriaBuilder.isTrue(root.get("imported"))

```

I get the following error:

```auto
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [imported] on this ManagedType [de.bayernlb.kundenportal.businessclasses.bankaccount.BankAccount]

```

If I try this:

```auto
criteriaBuilder.isTrue(root.get("bankAccountKey").get("imported"))

```

I get the following error:

```auto
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [bankAccountKey] on this ManagedType [de.bayernlb.kundenportal.businessclasses.bankaccount.BankAccount]
	at org.hibernate.metamodel.model.domain.internal.AbstractManagedType.checkNotNull(AbstractManagedType.java:147)
	at org.hibernate.metamodel.model.domain.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:118)
	at org.hibernate.metamodel.model.domain.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:43)
	at org.hibernate.query.criteria.internal.path.AbstractFromImpl.locateAttributeInternal(AbstractFromImpl.java:111)
	at org.hibernate.query.criteria.internal.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:204)
	at org.hibernate.query.criteria.internal.path.AbstractPathImpl.get(AbstractPathImpl.java:177)

```

Thanks for hints  
Thomas Mayr
