-->
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: Embeddable and Polymorphism
PostPosted: Mon Feb 25, 2008 6:39 pm 
Newbie

Joined: Mon Feb 25, 2008 6:29 pm
Posts: 1
I have classes and annotations as following.

class A {
@Embedded
B getB() {
return b;
}
}

@Embeddable
abstract class B {
}

class C extends B {
}

class D extends B {
}

See, I declare B an Embeddable entity. Also I turned on Discriminator parameters for B, C and D.

I try to persist instances of A.

A a = new A();
a.setB(new C());
session.save(a);

But Hibernate tries to instantiate an instance of B and save it, which fails since B is abstract. So my question is how to let Hibernate tell which is the real class to persist with? I tried @Target, but it only allows one class specified.

Best,
bonjovi


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.