我有这个实体:
@Entity
@Table(name = "Participant")
public class Participant {
@Column(name = "user")
User user;
@Column(name = "meet")
Meet meet;
@Enumerated(EnumType.STRING)
@Column(name = "rol")
Rol rol;
Meet 类是:
@Entity
@Table(name = "Meet")
public class Meet implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(unique = true, name = "name")
private String name;
@Enumerated(EnumType.STRING)
@Column(name = "state")
private State state;
我想通过 session 获得参与者
@Query("SELECT p FROM Participant p where p.meet= :id")
Participant findByMeet(@Param("id") Long id);
如何获取属于 session 的参与者列表
最佳答案
假设您在Participant
中有一个Long
的@Id
,它应该是这样的。
@Repository
public interface ParticipantRepository implements CrudRepository<Participant, Long> {
List<Participant> findAllByMeet(Meet meet);
}
Spring Data 将为您动态提供实现。
关于java - 如何通过 jpa 吸引参与者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56229794/