Hibernate PropertyNotFoundException:找不到setter

时间:2017-08-25 15:14:33

标签: java mysql hibernate

我的user_roles表包含带有用户表和角色的外键,如下所示

enter image description here

创建POJO后,我有以下类

Users
Roles
UserRoles
  +private Users users
  +private Roles roles
  +private UserRolesId id
UserRolesId

我想创建保存两个表信息Map

  public List<UserRolesJOIN> getUserRoles(String websiteID) {
        sf.getCurrentSession().beginTransaction();
        return sf.getCurrentSession().createCriteria(UserRoles.class, "ur")
                .createAlias("ur.users", "login")
                .createAlias("ur.roles", "roles")
            .setResultTransformer(Transformers.aliasToBean(UserRolesJOIN.class))
                .list();
    }


class UserRolesJOIN
  +login,roles with set/get

错误: 线程&#34; main&#34;中的例外情况org.hibernate.PropertyNotFoundException:找不到你的setter

at org.hibernate.property.ChainedPropertyAccessor.getSetter(ChainedPropertyAccessor.java:66)
    at org.hibernate.transform.AliasToBeanResultTransformer.initialize(AliasToBeanResultTransformer.java:121)
    at org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:84)
    at org.hibernate.loader.criteria.CriteriaLoader.getResultColumnOrRow(CriteriaLoader.java:148)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:753)

0 个答案:

没有答案