相关疑难解决方法(0)

在JPA查询中使用@Transient访问字段

我有一个具有transient属性的实体:

@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]

   }
Run Code Online (Sandbox Code Playgroud)

我试图locationIdentifier在JPA中访问这种方式:

String sqlString = "SELECT asset FROM Asset WHERE asset.locationIdentifier = :inputstr";
Query query = entityManager.createQuery(sqlString);
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个错误: Cannot resolve the property locationIdentifier

我想问一下如何locationIdentifier使用JPQL 访问?

对不起我的英语不好.提前致谢!

jpql

3
推荐指数
1
解决办法
9888
查看次数

标签 统计

jpql ×1