Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring数据JPA方法名_Java_Spring_Repository - Fatal编程技术网

Java Spring数据JPA方法名

Java Spring数据JPA方法名,java,spring,repository,Java,Spring,Repository,我需要关于Spring Data JPA存储库中方法名称的帮助,我有这样的实体: public class User { @Id @Column(name = "user_id", unique = true, nullable = false) private Integer userId; @Size(min = 3, message = "Login must be at least 3 characters!") @Column(name

我需要关于Spring Data JPA存储库中方法名称的帮助,我有这样的实体:

  public class User {

    @Id
    @Column(name = "user_id", unique = true, nullable = false)
    private Integer userId;

    @Size(min = 3, message = "Login must be at least 3 characters!")
    @Column(name = "login", length = 50, updatable = false, unique = true)
    private String login;

    @Size(min = 5, message = "Password must be at least 5 characters!")
    @JsonIgnore
    @Column(name = "password", length = 70)
    private String password;

    @Size(min = 3, message = "Name must be at least 3 characters!")
    @Column(name = "firstName", length = 70)
    private String firstName;

    @Size(min = 3, message = "Name must be at least 3 characters!")
    @Column(name = "lastName", length = 70)
    private String lastName;

       /**
     * Contains images uploaded by this user
     */
    @JsonIgnore
    @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, orphanRemoval = true)
    private Set<Image> images = new HashSet<Image>();

       * Contains requests submitted by this user
     */
    @JsonIgnore
    @OneToMany(mappedBy = "author", orphanRemoval = true, fetch = FetchType.LAZY)
    private Set<Request> requests = new HashSet<Request>();

    /**
     * Contains feedbackas provided by this user to hosters
     */
    @JsonIgnore
    @OneToMany(mappedBy = "author", orphanRemoval = true, fetch = FetchType.LAZY)
    private Set<Feedback> feedbacks = new HashSet<Feedback>();

    @JsonIgnore
    @OneToMany(mappedBy = "owner", fetch = FetchType.EAGER, orphanRemoval = true)
    private Set<Place> places;

    @OneToMany
    @JsonIgnore
    private Set<Place> bookedPlaces;

    @ManyToMany(fetch = FetchType.EAGER)
    @Cascade({ CascadeType.DELETE, CascadeType.PERSIST })
    @JsonIgnore
    @JoinTable(name = "user_place", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "place_id"))
    private Set<Place> attendee;
我使用的是SpringDataJPA,我需要编写一个方法,该方法将返回给我私有集attendee;
应该如何调用此方法???

我们是否应该假设您已经有了用户的存储库?去哪里?二者都都没有?该方法应该做什么?方法的命名不是基于它返回的内容,而是基于它的功能。使用javadoc提供完整的方法签名。@joragupra是的,我有我所有实体的存储库@JB Nizet,它应该返回给我certian UserList如果这些关系注释都正确,并且您从attendee中删除了@JsonIgnore,您只需询问userRepository即可。findById[用户id]。getAttendee;