Мне нужен метод репозитория весны, который позволяет мне получить список объектов Scene, используя список идентификаторов. Когда я пытаюсь обратиться к Идентификатору сцены, я получаю сообщение об ошибке, заявив, что не может найти свойство IdScene. Для этого я использую пользовательский запрос. Что-то не так с моим запросом?Запрос репозитория Spring JPA не может найти свойство ID
My Entity является
public class Scene implements Serializable
{
private long id_scene;
private Media media;
private int sceneNumber;
private int version;
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id_scene")
public long getIdScene() {
return id_scene;
}
public void setIdScene(long id_scene) {
this.id_scene = id_scene;
}
@ManyToOne
@JoinColumn(name = "id_media")
public Media getMedia() {
return this.media;
}
public void setMedia(Media media) {
this.media = media;
}
private List<Thumbnail> thumbnails = new ArrayList<Thumbnail>();
@OneToMany(mappedBy = "scene", cascade=CascadeType.ALL,
orphanRemoval=true)
@LazyCollection(LazyCollectionOption.FALSE)
public List<Thumbnail> getThumbnails() {
return this.thumbnails;
}
public void setThumbnails(List<Thumbnail> thumbnails) {
this.thumbnails = thumbnails;
}
public void addThumbnail(Thumbnail thumbnail) {
thumbnail.setScene(this);
this.thumbnails.add(thumbnail);
}
private Property property;
@OneToOne(mappedBy="scene", cascade=CascadeType.ALL,
orphanRemoval=true)
@LazyCollection(LazyCollectionOption.FALSE)
public Property getProperty() {
return property;
}
public void setProperty(Property property) {
this.property = property;
}
public void addProperty(Property property) {
property.setScene(this);
this.property = property;
}
@Column(name = "sceneNumber")
public int getSceneNumber() {
return sceneNumber;
}
public void setSceneNumber(int sceneNumber) {
this.sceneNumber = sceneNumber;
}
@Column(name = "version")
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
}
Мой репозиторий:
public interface SceneRepository extends JpaRepository<Scene, Long> {
public final static String FIND_BY_ID_LIST = "SELECT s"
+ " FROM Scene s WHERE s.IdScene IN (:id)";
@Query(FIND_BY_ID_LIST)
public List<Scene> findByIdScene(@Param("id") List<Long> id);//, Pageable page);
}
попробовать 'ы SELECT, от сцены с ГДЕ s.idScene В (: идентификатор)' отметить нижний регистр «я» в «idScene» –
@GarethDavis: это должен быть ответ. –
Спасибо, что это было. Зачем мне нужен нижний регистр? – user1988235