-->
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.  [ 4 posts ] 
Author Message
 Post subject: Annotations: extending a superclass that has no annotations
PostPosted: Fri Apr 08, 2005 2:39 pm 
Beginner
Beginner

Joined: Mon Mar 14, 2005 4:16 pm
Posts: 27
Hi,

I have a question related with annotations and polymorphism where the superclasses has no annotations at all. I would like to extend to existent classes (not persistent) with persistent subclasses (with annotations). Let's imagine this situation:

I have two superclasses, one of those uses the other

Code:
public class Driver {
}

public class Car {
      public Driver getDriver() {}
}


I would like to create to extend those two classes with persistent ones, let's say
Code:
@Entity
...
public class PersistentDriver extends Driver {
}

@Entity
public class PersistentCar extends Car {
    // THIS SHOULD RETURN A PERSISTENT DRIVER
     public Driver getDriver(){}
}


But, when registering the annotated classes in the
Code:
AnnotationConfiguration
, I get the exception
Code:
Could not determine type for: Driver
...
So, it is possible to subclass from classes that have not annotated attributes? Is there a way to return the Driver by using the PersistentDriver class?

Thanks in anticipation,

Bruno


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 08, 2005 2:46 pm 
Newbie

Joined: Thu Apr 07, 2005 6:09 pm
Posts: 3
I have experienced a similar issue when I have interfaces rather than your concrete base classes which are not @Entity classes. I would like to develop to the interfaces and implement to the @Entity beans. However in my tests I receive the same exception.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 8:46 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 4:16 pm
Posts: 27
With entities implementing interfaces you can use the parameter targetEntity in your one-to-manies, etc and it sould work ok... What I found after some test is that when you implement a base class (e.g. the getDriver method) you can put the @Transient annotation in the base method. However this creates a dependency with the base class and Hibernate and this is something I wanted to avoid. Is this expected behaviour?

Bruno


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 6:36 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
elmosca wrote:
However this creates a dependency with the base class and Hibernate and this is something I wanted to avoid. Is this expected behaviour?

Bruno

This will change when the new EJB3 spec draft will be out.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.