Hello Hibernate Folks,
I have the following properties block in my hibernate mapping:
<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:
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:
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
...
criteriaBuilder.isTrue(root.get("imported"))
I get the following error:
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:
criteriaBuilder.isTrue(root.get("bankAccountKey").get("imported"))
I get the following error:
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