I want to persist into DB 2 entities :
Attribute
@Entity public class Attribute<T> { @Id @GeneratedValue(strategy = AUTO) Long id; @ManyToOne @JoinColumn(name = "item_id") Item item; String name; T value; boolean isTemplate; // skip setter and getter }Item
public class Item { @Id @GeneratedValue(strategy = AUTO) Long id; @OneToMany(cascade = ALL) @JoinColumn(name= "item_id") List<Attribute> attributes; private boolean isTemplate; // skip setter and getter } in short Item 1-->* AttributeError message that i get because hibernate can't map T value;
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.hibernate.AnnotationException: Property domain.item.Attribute.value has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
I only need this simple table
- Item
| id:int | isTemplate:boolean | - Attribute
| id:int | Name:String | type:String (i.e:String,Integer - > based value type) | value:String | fk_item_id |
- Item
Thanks in advance for any help or suggestion to solve this problem.