我在两个表之间有一对一的关系,我使用@MapsId注释使两个表具有相同的id,我可以保存到具有相同id的两个表,现在出现问题,现在我想要进行一些查询以从表中检索数据,
我想让所有用户都知道userprofile.domain =“value”,有人可以帮我查询一下吗?
用户表
public class User{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(length = 50, unique = true, nullable = false)
private String login;
}
userprofile表
@Table(name = "userprofile")
public class Userprofile implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
@Column(name = "domain")
private String domain;
}
答案 0 :(得分:0)
修正了,让它与
一起使用@Query("Select user from User user join Userprofile userprofile on user.id=userprofile.id AND userprofile.domain=:domain")
public Page<User> FindAllWithDomain(Pageable pageable,@Param("domain")String domain);