Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWZlZjc3YTYw... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiOWZlZj... ) HHH-15553 ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiOWZlZj... ) Attributes not found for composite-key mappings: "java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name" ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiOWZlZj... )
Change By: Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... )
We migrated from Hibernate 3.6 to 5.6 and I am currently rewriting migrating legacy Criteria API calls to JPA CriteriaBuilder. When I try to call the method root.gey(key), I get this exception:
{{java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [userName] on this ManagedType [com.myapp.ums.business.impl.UmsUserRoleVOImpl]}}
The reason for this is that the attributes that are set as key-properties could not be found in {{AbstractManagedType#getAttribute(String name)}}:
!image-20220926-131848.png|width=1310,height=241!
Here is the code I use to prepare the DB queries:
{code:java}CriteriaBuilder cb = this.getSession().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(aliasToBeanClass);
Root root = cq.from(aliasToBeanClass); // aliasToBeanClass is set to UmsUserRoleVOImpl
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get(key), value)); // key is set to "userName" - this line is causing the exception
{code}
*My mapping file*
{{<?xml version="1.0"?>}}
{{<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"}}
{{ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">}}
{{<hibernate-mapping>}}
{{ <class name="com.myapp.ums.business.impl.UmsUserRoleVOImpl" table="ums_t_user_role"}}
{{ proxy="com.myapp.ums.common.business.UmsUserRoleVO">}}
{{ <composite-id>}}
{{ <key-property name="userName" type="java.lang.String" column="fk_user_id"/>}}
{{ <key-property name="roleName" type="java.lang.String" column="fk_role_id"/>}}
{{ </composite-id>}}
{{ </class>}}
{{</hibernate-mapping>}}
*The interface:*
{code:java}public interface UmsUserRoleVO extends AbstractBaseProperties {
String ROLE_NAME = "roleName";
String USER_NAME = "userName";
String PROPERTIES = "properties";
String getUserName();
void setUserName(final String userName);
String getRoleName();
void setRoleName(final String roleName);
List<PmPropertyVO> getProperties();
void setProperties(List<PmPropertyVO> properties);
}{code}
*The entity:*
{code:java}package com.myapp.ums.business.impl;
public class UmsUserRoleVOImpl extends AbstractBasePropertiesImpl implements UmsUserRoleVO {
private static final long serialVersionUID = 6390635151578885216L;
private String roleName;
private String userName;
private List<PmPropertyVO> properties;
public UmsUserRoleVOImpl() {
}
@Override
public Long getRowguid() {
return super.getRowguid();
}
@Override
public void setRowguid(final Long rowguid) {
super.setRowguid(rowguid);
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public List<PmPropertyVO> getProperties() {
return properties;
}
public void setProperties(List<PmPropertyVO> properties) {
this.properties = properties;
}
public boolean equals(Object o) {
...
}
public int hashCode() {
...
}
public String toString() {
return roleName + " " + userName;
}
@Get(UmsUserRoleVO.USER_NAME)
public String getUserName() {
return this.userName;
}
@Set(UmsUserRoleVO.USER_NAME)
public void setUserName(String userName) {
this.userName = userName;
}
}{code}
I think it has something to do with the mapping file not correctly processed.
( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )
Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNGU5NTM5NjBh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiNGU5NT... ) HHH-15553 ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiNGU5NT... ) Attributes not found for composite-key mappings: "java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name" ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiNGU5NT... )
Change By: Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... )
We migrated from Hibernate 3.6 to 5.6 and I am currently rewriting legacy Criteria API calls to JPA CriteriaBuilder. When I try to call the method root.gey(key), I get this exception:
{{java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [userName] on this ManagedType [com.myapp.ums.business.impl.UmsUserRoleVOImpl]}}
The reason for this is that the attributes that are set as key-properties could not be found in {{AbstractManagedType#getAttribute(String name)}}:
!image-20220926-131848.png|width=1310,height=241!
Here is the code I use to prepare the DB queries:
{code:java}CriteriaBuilder cb = this.getSession().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(aliasToBeanClass);
Root root = cq.from(aliasToBeanClass); // aliasToBeanClass is set to UmsUserRoleVOImpl
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get(key), value)); // key is set to "userName" - this line is causing the exception
{code}
*My mapping file*
{{<?xml version="1.0"?>}}
{{<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"}}
{{ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">}}
{{<hibernate-mapping>}}
{{ <class name="com.myapp.ums.business.impl.UmsUserRoleVOImpl" table="ums_t_user_role"}}
{{ proxy="com.myapp.ums.common.business.UmsUserRoleVO">}}
{{ <composite-id>}}
{{ <key-property name="userName" type="java.lang.String" column="fk_user_id"/>}}
{{ <key-property name="roleName" type="java.lang.String" column="fk_role_id"/>}}
{{ </composite-id>}}
{{ </class>}}
{{</hibernate-mapping>}}
*The interface:*
{code:java}public interface UmsUserRoleVO extends AbstractBaseProperties {
String ROLE_NAME = "roleName";
String USER_NAME = "userName";
String PROPERTIES = "properties";
String getUserName();
void setUserName(final String userName);
String getRoleName();
void setRoleName(final String roleName);
List<PmPropertyVO> getProperties();
void setProperties(List<PmPropertyVO> properties);
}{code}
*The entity:*
{code:java}package com.myapp.ums.business.impl;
public class UmsUserRoleVOImpl extends AbstractBasePropertiesImpl implements UmsUserRoleVO {
private static final long serialVersionUID = 6390635151578885216L;
private String roleName;
private String userName;
private List<PmPropertyVO> properties;
public UmsUserRoleVOImpl() {
}
@Override
public Long getRowguid() {
return super.getRowguid();
}
@Override
public void setRowguid(final Long rowguid) {
super.setRowguid(rowguid);
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public List<PmPropertyVO> getProperties() {
return properties;
}
public void setProperties(List<PmPropertyVO> properties) {
this.properties = properties;
}
public boolean equals(Object o) {
...
}
public int hashCode() {
...
}
public String toString() {
return roleName + " " + userName;
}
@Get(UmsUserRoleVO.USER_NAME)
public String getUserName() {
return this.userName;
}
@Set(UmsUserRoleVO.USER_NAME)
public void setUserName(String userName) {
this.userName = userName;
}
}{code}
I think it has something to do with the mapping file not correctly processed.
( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )
Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTFmZGEwOWI1... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTFmZG... ) HHH-15553 ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTFmZG... ) Attributes not found for composite-key mappings: "java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name" ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTFmZG... )
Change By: Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... )
We migrated from Hibernate 3.6 to 5.6 and I am currently rewriting legacy Criteria API calls to JPA CriteriaBuilder. When I try to call the method root.gey(key), I get this exception:
{{java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [userName] on this ManagedType [com.myapp.ums.business.impl.UmsUserRoleVOImpl]}}
The reason for this is that the attributes that are set as key-properties could not be found in {{AbstractManagedType#getAttribute(String name)}}:
!image-20220926-131848.png|width=1310,height=241!
Here is the code I use to prepare the DB queries:
{code:java}CriteriaBuilder cb = this.getSession().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(aliasToBeanClass);
Root root = cq.from(aliasToBeanClass); // aliasToBeanClass is set to UmsUserRoleVOImpl
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get(key), value)); // key is set to "userName" - this line is causing the exception
{code}
*My mapping file*
{{<?xml version="1.0"?>}}
{{<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"}}
{{ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">}}
{{<hibernate-mapping>}}
{{ <class name="com.myapp.ums.business.impl.UmsUserRoleVOImpl" table="ums_t_user_role"}}
{{ proxy="com.myapp.ums.common.business.UmsUserRoleVO">}}
{{ <composite-id>}}
{{ <key-property name="userName" type="java.lang.String" column="fk_user_id"/>}}
{{ <key-property name="roleName" type="java.lang.String" column="fk_role_id"/>}}
{{ </composite-id>}}
{{ </class>}}
{{</hibernate-mapping>}}
*The interface:*
{code:java}public interface UmsUserRoleVO extends AbstractBaseProperties {
String ROLE_NAME = "roleName";
String USER_NAME = "userName";
String PROPERTIES = "properties";
String roleName = "roleName";
String userName = "userName";
String getUserName();
void setUserName(final String userName);
String getRoleName();
void setRoleName(final String roleName);
List<PmPropertyVO> getProperties();
void setProperties(List<PmPropertyVO> properties);
}{code}
*The entity:*
{code:java}package com.myapp.ums.business.impl;
public class UmsUserRoleVOImpl extends AbstractBasePropertiesImpl implements UmsUserRoleVO {
private static final long serialVersionUID = 6390635151578885216L;
private String roleName;
private String userName;
private List<PmPropertyVO> properties;
public UmsUserRoleVOImpl() {
}
@Override
public Long getRowguid() {
return super.getRowguid();
}
@Override
public void setRowguid(final Long rowguid) {
super.setRowguid(rowguid);
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public List<PmPropertyVO> getProperties() {
return properties;
}
public void setProperties(List<PmPropertyVO> properties) {
this.properties = properties;
}
public boolean equals(Object o) {
...
}
public int hashCode() {
...
}
public String toString() {
return roleName + " " + userName;
}
@Get(UmsUserRoleVO.USER_NAME)
public String getUserName() {
return this.userName;
}
@Set(UmsUserRoleVO.USER_NAME)
public void setUserName(String userName) {
this.userName = userName;
}
}{code}
I think it has something to do with the mapping file not correctly processed.
( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )
Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTRlODNlZGEz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTRlOD... ) HHH-15553 ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTRlOD... ) Attributes not found for composite-key mappings: "java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name" ( https://hibernate.atlassian.net/browse/HHH-15553?atlOrigin=eyJpIjoiZTRlOD... )
Issue Type: Bug Affects Versions: 5.6.11 Assignee: Unassigned Attachments: image-20220926-131848.png Created: 26/Sep/2022 06:21 AM Priority: Major Reporter: Patrick Lübbecke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61a7428... )
We migrated from Hibernate 3.6 to 5.6 and I am currently rewriting legacy Criteria API calls to JPA CriteriaBuilder. When I try to call the method root.gey(key), I get this exception:
java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [userName] on this ManagedType [com.myapp.ums.business.impl.UmsUserRoleVOImpl]
The reason for this is that the attributes that are set as key-properties could not be found in AbstractManagedType#getAttribute(String name) :
Here is the code I use to prepare the DB queries:
CriteriaBuilder cb = this.getSession().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(aliasToBeanClass);
Root root = cq.from(aliasToBeanClass); // aliasToBeanClass is set to UmsUserRoleVOImpl
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get(key), value)); // key is set to "userName" - this line is causing the exception
*My mapping file*
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
{{ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">}}
<hibernate-mapping>
{{ <class name="com.myapp.ums.business.impl.UmsUserRoleVOImpl" table="ums_t_user_role"}}
{{ proxy="com.myapp.ums.common.business.UmsUserRoleVO">}}
{{ <composite-id>}}
{{ <key-property name="userName" type="java.lang.String" column="fk_user_id"/>}}
{{ <key-property name="roleName" type="java.lang.String" column="fk_role_id"/>}}
{{ </composite-id>}}
{{ </class>}}
</hibernate-mapping>
*The interface:*
public interface UmsUserRoleVO extends AbstractBaseProperties {
String ROLE_NAME = "roleName" ;
String USER_NAME = "userName" ;
String PROPERTIES = "properties" ;
String roleName = "roleName" ;
String userName = "userName" ;
String getUserName();
void setUserName( final String userName);
String getRoleName();
void setRoleName( final String roleName);
List<PmPropertyVO> getProperties();
void setProperties(List<PmPropertyVO> properties);
}
*The entity:*
package com.myapp.ums.business.impl;
public class UmsUserRoleVOImpl extends AbstractBasePropertiesImpl implements UmsUserRoleVO {
private static final long serialVersionUID = 6390635151578885216L;
private String roleName;
private String userName;
private List<PmPropertyVO> properties;
public UmsUserRoleVOImpl() {
}
@Override
public Long getRowguid() {
return super.getRowguid();
}
@Override
public void setRowguid( final Long rowguid) {
super.setRowguid(rowguid);
}
public String getRoleName() {
return roleName;
}
public void setRoleName( String roleName) {
this.roleName = roleName;
}
public List<PmPropertyVO> getProperties() {
return properties;
}
public void setProperties(List<PmPropertyVO> properties) {
this.properties = properties;
}
public boolean equals( Object o) {
...
}
public int hashCode() {
...
}
public String toString() {
return roleName + " " + userName;
}
@Get(UmsUserRoleVO.USER_NAME)
public String getUserName() {
return this.userName;
}
@Set(UmsUserRoleVO.USER_NAME)
public void setUserName( String userName) {
this.userName = userName;
}
}
I think it has something to do with the mapping file not correctly processed.
( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15553#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )