![](/img/trans.png)
[英]How to use JPA to generate jointable where an entity joins with a join table?
[英]Use WHERE in JPA to query the entity
我有这个实体:
@Entity
@Table
public class Terminals implements Serializable {
private static final long serialVersionUID = 5288308199642977991L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
@Column
private int merchant_id;
@Column
private String terminalToken;
.....
}
我尝试使用此查询:
public Terminals getTerminalToken(String terminalToken) throws Exception {
return entityManager.find(Terminals.class, terminalToken);
}
看起来它只是在选择表键。
如何选择表列terminalToken
?
如果您正在寻找纯Java(我更赞成Philipp解决方案),也许您想看看这个解决方案。 https://www.objectdb.com/java/jpa/query/criteria 。 很抱歉没有发布直接的解决方案,但我想为您提供更多信息。
顺便说一句,为什么不使用弹簧数据? 容易得多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.