我无法为此类中的字段树获得正确的映射:
@Entity
@Table(name = "SushiMapTree")
public class SushiMapTree<K, V> extends Persistable implements Map<K,V> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="SushiMapID")
protected int ID;
@OneToOne(cascade = CascadeType.ALL)
@JoinTable(name="SushiMapTree_SushiTree")
private SushiTree<SushiMapElement<K, V>> tree = new SushiTree<SushiMapElement<K,V>>();
这是其他类及其映射:
@Entity
@Table(name = "SushiTree")
public class SushiTree<T> extends Persistable implements Collection<T> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="SushiTreeID")
protected int ID;
@Column(name="Test")
private String test = "Test";
@OneToMany(cascade = CascadeType.PERSIST)
@JoinTable(name="SushiTree_SushiTreeElements")
private List<SushiTreeElement<T>> treeElements = new ArrayList<SushiTreeElement<T>>();
@OneToMany(cascade = CascadeType.PERSIST)
@JoinTable(name="SushiTree_SushiTreeRootElements")
private List<SushiTreeElement<T>> treeRootElements = new ArrayList<SushiTreeElement<T>>();
}
@Entity
@Table(name = "SushiMapElement")
public class SushiMapElement<K, V> extends Persistable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int ID;
@ManyToOne(cascade = CascadeType.PERSIST)
private SushiMapElement<K, V> parent;
@OneToMany(cascade = CascadeType.PERSIST)
private List<SushiMapElement<K, V>> children = new ArrayList<SushiMapElement<K, V>>();
@Column(name = "MapKey")
K key;
@Column(name = "MapValue")
V value;
其他类运行良好,但我无法获得正确的映射。我用 Column、JoinColumn、JoinTable 等尝试了几个小时的不同映射。Eclipse Link 不会创建数据库并说要使用 ValueHolderInterface:
The attribute [tree] is not declared as type ValueHolderInterface, but its mapping uses indirection.
谢谢你的帮助!