-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: OneToMany association problem
PostPosted: Thu Apr 02, 2009 9:57 am 
Newbie

Joined: Wed Apr 01, 2009 11:06 am
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 2:37 am 
Newbie

Joined: Mon Mar 23, 2009 5:56 am
Posts: 6
Hi !

If you didnt solve your problem already:

It seems you have forgotten to map the org.quartz.Job class in your
hibernate.cfg.xml

<mapping class="org.quartz.Job"/>

regards

Michael


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 3:32 am 
Newbie

Joined: Wed Apr 01, 2009 11:06 am
Posts: 5
Thx for the tip. I did solve the problem.
The problem was that I was autoresolving the imports, and it mixed the javax.persistence imports with org.hibernate imports


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.