PlaylistItem
IDで特定のArtContent
-s を参照するすべての -s を削除する JPQL クエリを作成しようとしていますArtContent
。
私はこれを試しました:
public int deleteItemsByContentIds(Long[] contentIds) {
EntityManager em = getEntityManager();
int result = em.createQuery(
"delete from PlaylistItem where artContent.id in (:idsArray) ")
.setParameter("idsArray", contentIds).executeUpdate();
return result;
}
しかし、それは例外をスローします:
Servlet.service() for servlet RemoveContentServlet threw exception:
javax.ejb.EJBException: java.lang.IllegalArgumentException:
Encountered array-valued parameter binding, but was expecting [java.lang.Long]
setParameter
配列を引数として取るメソッドがないため、理解できます。では、このような問題を解決する最善の方法は何ですか?
簡略化されたクラス定義:
@Entity
public class PlaylistItem implements Serializable {
@Id
@GeneratedValue
private Long id;
private int position;
@ManyToOne(optional = false)
@JoinColumn(name = "PLAYLIST_ID")
private Playlist playlist;
@ManyToOne(optional = false)
@JoinColumn(name = "ART_CONTENT_ID")
private ArtContent artContent;
...
}
@Entity
public class ArtContent implements Serializable {
@Id
@GeneratedValue
private Long id;
...
}