我有这个实体:
@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;
和类见面是:
@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;
我想参加聚会
@Query("SELECT p FROM Participant p where p.meet= :id")
Participant findByMeet(@Param("id") Long id);
如何获取参加会议的参与者列表
最佳答案
假设您在@Id
中的Long
为Participant
,则应该像这样。
@Repository
public interface ParticipantRepository implements CrudRepository<Participant, Long> {
List<Participant> findAllByMeet(Meet meet);
}
Spring Data将为您动态提供实现。