-->
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.  [ 1 post ] 
Author Message
 Post subject: Map interface with multiple implementations
PostPosted: Thu Aug 06, 2009 3:29 am 
Newbie

Joined: Mon Mar 10, 2008 8:55 am
Posts: 9
Hi,

I'm using hibernate 3.2.6 (mapping with annotations) and I'm having an issue regarding mapping of an interface (or some trick to make it work) :\
This is my situation:

Code:
public interface IFoo {
   public void doSomething();
}

@Entity
public class A implements IFoo {
   public void doSomething() {}
}

@Entity
public class B extends SomethingForBNotForA implements IFoo {
   public void doSomething() {}
}

@Entity
public class C extends B {
}

// I want to map the interface here
@Entity
public class Bar {

    @ManyToOne
    private IFoo foo;

}


Now there's a class that contains any objects of IFoo.
Is there any proper way to map this with hibernate ? I tried to use @MappedSuperClass, but that's not working on interfaces. I thought of making an abstract class of the interface, but that's going to give troubles since B already extends from another class which is not always IFoo.

*UPDATE*
I should be able to create a table in the db with Id and DTYPE as columns, I guess...

Thanks in advance, any suggestions are appreciated !


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

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.