Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA @Embeddable

I am using @ElementCollection for a custom object list

@ElementCollection
@CollectionTable(name = "choice", joinColumns = @JoinColumn(name = "itemId"))
@OrderColumn(name = "index")
private List<Choice> choices = new ArrayList<Choice>();

I have created a Choice class like this

//@Embeddable
@Table(name = "choice")
@Cacheable(false)
@Audited
public class Choice implements Serializable{

If I use @Embeddable annotation I am getting org.hibernate.MappingException: Type not supported for auditing: org.hibernate.type.ComponentType

I am new to JPA. Is there anything that I am missing?

like image 617
user1161961 Avatar asked Jan 21 '12 06:01

user1161961


1 Answers

If you want to use @Embeddable, the field that refers to the @Embeddable class needs to have the @Embedded annotation. Then, the fields in the @Embedded class need to have proper JPA annotations so JPA knows what to do with them. You may want to read this in order to fully understand what @Embbedable does.

like image 153
Christine Avatar answered Sep 23 '22 07:09

Christine