I try to do a very simple OneToMany association using JPA annotations, but it doesn't seem to work
in User:
Code:
@Entity
@Table(name = "USERS")
public class User implements Serializable {
private static final long serialVersionUID = 7125941441868989498L;
/** User's id in the corresponding table */
@Id
@GeneratedValue
@Column(name = "USER_ID")
private Long id = null;
@OneToMany(mappedBy="user")
Collection<Job> dispatchedJobs = new ArrayList<Job>();
in Job:
Code:
@Entity
@Table(name="JOBS")
public class Job implements Serializable{
@Id
@GeneratedValue
@Column(name="JOB_ID")
private Long id = null;
@ManyToOne
@JoinColumn(name = "USER_ID", nullable = false, updatable = false)
private User user;
}
and I get this:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: model.User.dispatchedJobs[org.quartz.Job]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:252)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at test.Test.main(Test.java:13)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: model.User.dispatchedJobs[org.quartz.Job]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1016)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:567)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:508)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1112)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:240)
thx in advance