Hi guys,

I must be missing something simple to get generics working with openjpa:

this is a very simple example.

@MappedSuperclass
public class Fruit {}

@Entity
public class Apple extends Fruit {}

@Entity
public class Orange extends Fruit {}

@MappedSuperclass
public class Tree<T extends Fruit> {

@ManyToOne (cascade = CascadeType.ALL) // targetEntity ?
@JoinColumn
private T fruit;

//getters setters

}

@Entity
public class AppleTree extends Tree<Apple> {}

@Entity
public class OrangeTree extends Tree<Orange> {}


@Test
Apple fruit = new AppleFruit();
AppleTree tree = new AppleTree();
tree.setFruit(fruit);
//save  tree
//after saving we should be able to retrieve AppleTree with Apple fruit

openjpa seems cannot guess targetEntity on @ManyToOne

what is way to get it working? 

Out of despair I even tried using @ManyToOne with targetEntity specified on
subclasses (declaring on a method not a field level) does not work either.
(And I don't like this approach).

Help is greatly appreciated.

Agurkas



-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/very-simple-generics-example-but-how-to-make-it-work-with-openjpa-tp5963498p5963498.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to