我有一个班级评论:
@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();
throws org.hibernate.exception.DataException:没有为参数 1 指定值。
这是构建的查询:
选择 this_.comment_id 作为comment1_0_0_,this_.comment 作为comment0_0_,commenttop2_.comment_id 作为comment1_0_2_,commenttop2_.topic 作为topic2_ 从评论中选择this_ left outer join comments_topic commenttop2_ on this_.comment_id=commenttop2_.comment_id where this_.comment_id=?
我是否使用了不正确的注释?
条件查询是否构造不正确?