Hello,
I am new to JPA/Hibernate, so this might be a trivial question. Apologies upfront.
I am trying to persist a generic Value object either using generics or inheritance.
Using inheritance I have something like
Code:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
abstract class Value {
@Id @GeneratedValue int id;
abstract double getDouble();
abstract int getInt();
abstract String getStr();
}
@Entity
class DoubleValue extends Value {
double dv;
...
}
@Entity
class StringValue extends Value {
String sv;
...
}
I then try to use this in another class
@Entity(name="Pg1g")
public class Pg1G {
@Id @GeneratedValue int id;
Value v;
...
}
Unfortunately that does not work. I get
Quote:
Could not determine type for: pg.ejb3.Value, for columns: [org.hibernate.mapping.Column(v)]
I also tried to get this going with generics but that also failed.
So...what is the recommended approach to have something like the Value class from above as a member in another class (preferrable Embedded) and get that persisted?
Any advice or pointers warmly welcomed!
Peter
PS I am using
Hibernate version:
3.2.2
Name and version of the database you are using:
mySql 5