0
我有一個類註釋:休眠條件查詢爲多對多枚舉
@Entity
@Table(name = Constants.COMMENTS_TABLE)
@Audited
public class Comment {
@Column(name = "comment", nullable = false)
private String comment;
@ElementCollection(targetClass = CommentTopic.class)
@Enumerated(EnumType.STRING)
@Fetch(value = FetchMode.JOIN)
@CollectionTable(name = Constants.COMMENTS_TOPIC_JOIN_TABLE, joinColumns = @JoinColumn(name = "comment_id"))
@Column(name = "topic")
private Set<CommentTopic> commentTopics;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "comment_id", nullable = false)
private Long commentId;
}
堅持的評論類作品,但下列條件查詢:
Criteria criteria = session.createCriteria(Comment.class)
.add(Restrictions.eq("commentTopics", topic));
List<Comment> entries = criteria.list();
拋出org.hibernate.exception.DataException :沒有爲參數1指定值。
這是查詢內置的:
se將this_.comment_id作爲comment1_0_0_,this_.comment作爲comment0_0_,commenttop2_.comment_id作爲comment1_0_2_,commenttop2_.topic作爲topic2_從評論this_ left外部連接comments_topic commenttop2_在this_.comment_id = commenttop2_.comment_id其中this_.comment_id =?
我使用不正確的註釋嗎?
標準查詢是否未正確構建?