我有一个具有瞬态属性的实体:
@Entity
@Table(name = "asset")
public class Asset {
@Transient
private String locationIdentifier = "N/A";
@SuppressWarnings("unused")
@PostLoad
private void onPostLoad() {
if (location != null) {
locationIdentifier = location.getIdentifier();
}
}
[other stuffs]
}
我试图locationIdentifier
在 JPA 中以这种方式访问:
String sqlString = "SELECT asset FROM Asset WHERE asset.locationIdentifier = :inputstr";
Query query = entityManager.createQuery(sqlString);
但我得到一个错误:Cannot resolve the property locationIdentifier
我想问一下我如何locationIdentifier
使用JPQL访问?
对不起我的英语不好。提前致谢!