-->
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: Inheritance accross 2 ears
PostPosted: Fri Nov 17, 2006 6:57 pm 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hibernate version: 3.2.0CR2

Mapping documents: None Annotations being used


I have a situation where i have entities split over 2 jar files (packed in seperate .ear archives, with seperate Persistence Units). When i deploy the first file, i encounter no problems at all when deploying the first jar file. The first Jar file has a bidirectionial OneToOne relationship like so:

Entity A
Code:
@Entity
@Inheritence(strategy = InheritenceType.JOINED) //needed for the second jar
public class A {

   private B;
   .....
   @OneToOne(mappedBy = a)
   public B getB() {
      return B;
   }
   .....
}


Entity B
Code:
@Entity
public class B {

   private A;
   .....
   @OneToOne
   @JoinColumn(name = "A_FK")
   public A getA() {
      return A;
   }
   .....
}



The problem occurs when i deploy the second jar (contained within a differnet .ear archive) which extends A. When doing this i am getting and "org.hibernate.AnnotationException mappedBy references unknown property". Is this due to the fact that A and B are in a seperate .ear archive to the class that extends A (do i need to set the classpath somewhere)? Or is it something else all together ??

Thanks in advance,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you might be able to use the <class>...</class> element in your persistence.xml but somehow, the class has to be in the EAR classpath scope

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 24, 2006 10:42 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
The orginal problem was fixed while i was at JBoss world :-), but now the we are experiencing some different problems that i think are related.

We have a similar setup with inheritiance accross multiple .ear archives, the classes in the different ears are managed by different Persistence Context and thus by different EntityManagers. The exception we are now getting is a when trying to persist a class that inherits

Code:
org.hibernate.HibernateException: instance is not of excepected type : <grandchild entity>
is not a: <parent entity>

but this is not the case, as via the class.getSuperclass methods it can be seen that the granchild is of the same type as the parent.

We are currently trying to persist the parent type, but a this could be a grandchild. The inheritance is table per subclass (or InheritanceType.JOINED)

Is the fact that grandchild's entitymanager does not know about the parent what causes the problem ? Or is it the way that we are trying to persist the objects the problem ?

Any suggestions ?

Cheers,

Andy

_________________
Rules are only there to be broken


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.