gpt4 book ai didi

java - 游戏框架中的订单相关实体

转载 作者:行者123 更新时间:2023-12-02 03:54:21 24 4
gpt4 key购买 nike

假设我在 play 框架中有两个实体类,java:

@Entity
public class User extends Model implements Validation {
@Id
private String email;
private String password;
@OneToOne
@PrimaryKeyJoinColumn(referencedColumnName = "userEmail")
private Address address;}

@Entity
public class Address extends Model{
@Id
@Column(name="userEmail")
private String email;
private String streetName;
private String city;
private String country;}

现在我想从数据库中检索所有用户并根据地址模型的 streetName 属性对它们进行排序。我用过这个List<Restaurant> list = Restaurant.find.order("streetName asc").findList();

但我收到以下错误:

[PersistenceException: Query threw SQLException:Unknown column 'streetName' in 'order clause' 
Bind values:[]

如果我将任何 User 属性作为订单字符串 ( ...order("email asc").findList(); ),它会起作用并且我会得到有序列表,但如何才能使其根据 Address 属性对用户进行排序?

最佳答案

尝试 Restaurant.find.order("address.streetName asc").findList()

关于java - 游戏框架中的订单相关实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35628407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com