-->
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: How to inherit a abstract base class with a generic element?
PostPosted: Wed May 07, 2008 3:47 am 
Newbie

Joined: Mon Aug 21, 2006 12:44 pm
Posts: 12
Hello everybody,

I have the following situation:

An abstract base class with a generic element.

Code:
@Entity
class abstract abstractBaseClass <T>{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer Id;

    private T element;
}


Some of the following classes:

Code:
@Entity
class A extends abstractBaseClass <KlasseX>{
    @ManyToOne(targetEntity = KlasseX.class)
    public KlasseX getElement() {
    }
}

@Entity
class B extends abstractBaseClass <KlasseY>>{
    @ManyToOne(targetEntity = KlasseY.class)
    public KlasseY getElement() {
}

@Entity
class C extends abstractBaseClass <KlasseZ>{
    @ManyToOne(targetEntity = KlasseZ.class)
    public KlasseZ getElement() {
}



Everything works just fine, when I use (strategy = InheritanceType.JOINED) in the abstractBaseClass

But because of performance issues I rather use @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) to have a single table per class. But that somehow does not work. I also read some about it and it is not realy recomended.

However, I could live with the SINGLE_TABLE sollution, but the generic type makes this impossible to use. I get constraint violation exceptions from the Database (of course I do)

The sollution must work with Oracle and MsSQL, so a sollution just for one DB System is not the desired one.

I hope I could make myself clear and someone can help me with it.

greets
Santo.


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.