在hibernate5中使用集合时,是否需要@OrderColumn批注?

时间:2019-07-19 20:34:47

标签: hibernate-5.x

我正在编写一个持久性类,它有一个collections字段,我想在使用collections时跳过@OrderColumn注释。我该怎么做?

我尝试跳过@OrderColumn,但抛出异常。当我添加@OrderColumn时,它会正常工作

@ElementCollection
@CollectionTable(name="mycourses",joinColumns=@JoinColumn(name="mysid"))@Column(name="courseName")
private String course[];
The above code gives exception
i get the following exception -
org.hibernate.AnnotationException: List/array has to be annotated with an @OrderColumn (or @IndexColumn): collection.Student1.course
@ElementCollection
@CollectionTable(name="mycourses",joinColumns=@JoinColumn(name="mysid"))@Column(name="courseName")
@OrderColumn
private String course[];

但这很好用!

0 个答案:

没有答案