私のクラス:
public class User
{
@Type(type="AccountType")
private AccountType accountType;
}
public class AccountType
{
private String name;
private AccountType(String name)
{
this.name = name;
}
public static AccountType User = new AccountType("User");
public static AccountType Administrator = new AccountType("Administrator");
}
また、AccountTypeUserTypeを適切に設定しています。
私の質問:
List results = session.createCriteria(User.class)
.setProjection(Projections.projectionList()
.add(Projections.property("accountType.name"), "accountType)
)
.setResultTransformer(Transformer.aliasToBean(UserSummary.class))
.list()
私が遭遇した問題は、私のクエリが次のように失敗することです...
org.hibernate.QueryException: could not resolve property: accountType.name of: com.huskyenergy.routecommander.domain.rtc.User
ああ、accountTypeは関連付けではないため、.createAlias( "accountType"、 "at")もできません。
何かご意見は?