Code:
@Entity
@Table(name = "TBL_DATATREE")
@SequenceGenerator(name = "SEQUENCE", sequenceName = "SQ_TBL", allocationSize = 1)
public class ProjectDataTree extends CHibernate implements Serializable
{
/** automatisch generiert */
private static final long serialVersionUID = -271046672593565385L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE")
@Column(name = "NDATAID", precision = 18, scale = 0)
long l_DataId;
@Column(name = "NPARENTDATAID", precision = 18, scale = 0, insertable = false, updatable = false)
private Long l_ParentDataId;
@Column(name = "NTYPE", precision = 18, scale = 0, updatable = false, insertable = false)
private long l_Type;
@Column(name = "NREFID", precision = 18, scale = 0, updatable = false, insertable = false)
private long l_RefId;
// Any Mapping
@Any(metaColumn = @Column(name = "NTYPE"), fetch = FetchType.EAGER)
@AnyMetaDef(idType = "long", metaType = "string", metaValues = {
@MetaValue(targetEntity = Car.class, value = "1"),
@MetaValue(targetEntity = Brand.class, value = "2"),
@MetaValue(targetEntity = Model.class, value = "3") })
@JoinColumn(name = "NREFID")
private Object obj_Object;
// Mapping Vater-Kind Beziehung auf diese Tabelle
@ManyToOne(fetch = FetchType.EAGER, optional = true)
@JoinColumn(name = "NPARENTDATAID", nullable = true)
private ProjectDataTree obj_ParentNode = null;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "obj_ParentNode", orphanRemoval = true)
@OrderBy("l_DataId desc")
private Set<ProjectDataTree> hs_ChildrenNodes = new HashSet<ProjectDataTree>(0);
/.. Getter u. Setter
}
wie werden die Daten am besten in der Datenbank gespeichert. Gibt es die Möglicchkeit Parent and Child geleichzeitig zu speichern?
Danke
Salamunti