-->
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.  [ 5 posts ] 
Author Message
 Post subject: Exception bei einer 1:n Beziehung (evtl.CoC-Fehler?!)
PostPosted: Thu Sep 23, 2010 4:01 am 
Newbie

Joined: Thu Apr 08, 2010 8:47 am
Posts: 18
Guten Morgen!

Ich habe ein kleines Problem beim Erstellen meiner DB bzw. meiner SessionFactory.
Zunächst mal ein Teil meines ERDs, ich habe alles bidirektional gemacht. Leider gibt es in der Entity "Workspace" oder "Project_Workspace" diesen Fehler.
Image
Mein Code in Workspace:
Code:
@Entity
@SuppressWarnings("serial")
public class Workspace extends AbstractIndexedObject implements Serializable {
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   private int id;
   private String workspace;
   @OneToMany(mappedBy = "workspace")
   private Collection<Workspace_ObjectIcon> workspace_ObjectIcon = new ArrayList<Workspace_ObjectIcon>();
   
   @OneToMany(mappedBy = "workspace")
// Hier muss der Fehler versteckt sein.
   private Collection<Project_Workspace> project_Workspace = new ArrayList<Project_Workspace>();
   ...

Mein Project_Workspace Code (vorsichtshalber):
Code:
@Entity
@SuppressWarnings("serial")
public class Project_Workspace implements Serializable {

   @Embeddable
   public static class Id implements Serializable{
      @SuppressWarnings("unused")
      private int workspaceId;
      @SuppressWarnings("unused")
      private int projectId;
      
      public Id(){
         super();
      }
      
      public Id(int workspaceId,int projectId){
         super();
         this.workspaceId = workspaceId;
         this.projectId = projectId;
      }
   }
   
   @EmbeddedId
   private Id id = new Id();
//Evtl. Hier
   @ManyToOne
   @JoinColumn(name = "workspace",insertable = false, updatable = false)
   private Workspace workspace;
   ...

Und bekomme folgende Exception:
Code:
Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: de.XXX.model.concrete.Workspace.project_Workspace[de.XXX.model.concrete.Project_Workspace]

Ich habe nach dem Problem viel gegoogelt, aber dass einzige was ich erfahren habe ist, dass angeblich Collection von Collections nicht möglich mit JPA ist und es angeblich mit der Hibernate-Annotation @CollectionOfElements (Vorsicht Hibernate "verlässt" JPA) möglich ist. Hat aber bei mir nicht funktioniert und ich sehe auch keine Collection von Collections bei mir.
Brauche eure Hilfe!!! :)

Vielen Dank im Voraus und viele Grüße
MK

PS: Mir ist als "Subject" nichts besseres eingefallen, seid bitte gnädig :)

Edit: Ahja, wenn ich die Getter/Setter des Attributes und das Attr. selber entferne, dann klappt alles! KA


Top
 Profile  
 
 Post subject: Re: Exception bei einer 1:n Beziehung (evtl.CoC-Fehler?!)
PostPosted: Thu Sep 23, 2010 8:08 am 
Newbie

Joined: Thu Sep 23, 2010 4:43 am
Posts: 10
Hi,

You need to define target entity,

targetEntity = ????,

you only put @ManyToOne annotation, you should specify the mapping entity class


Top
 Profile  
 
 Post subject: Re: Exception bei einer 1:n Beziehung (evtl.CoC-Fehler?!)
PostPosted: Thu Sep 23, 2010 8:38 am 
Newbie

Joined: Thu Apr 08, 2010 8:47 am
Posts: 18
Hi,

i tried both:
1. In Workspace:
@OneToMany(mappedBy = "workspace", targetEntity = Project_Workspace.class)
and
2. In Project_Workpspace:
@ManyToOne(targetEntity = Workspace.class)

Both didn't work. I thought "targetEntity" is only needed, if i use non-Generics or?

Greets
MK


Top
 Profile  
 
 Post subject: Re: Exception bei einer 1:n Beziehung (evtl.CoC-Fehler?!)
PostPosted: Thu Sep 23, 2010 9:03 am 
Newbie

Joined: Thu Sep 23, 2010 4:43 am
Posts: 10
you should also provide other relationships between other entities.


Top
 Profile  
 
 Post subject: Re: Exception bei einer 1:n Beziehung (evtl.CoC-Fehler?!)
PostPosted: Thu Sep 23, 2010 1:06 pm 
Newbie

Joined: Thu Apr 08, 2010 8:47 am
Posts: 18
Sorry, i can't follow you. This is the whole ERD:
Image
Can you show me the Code you meant please? I want to test it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.