Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Parent-Node gelichzeitig speichern
PostPosted: Tue Dec 09, 2014 7:47 am 
Newbie

Joined: Tue Dec 09, 2014 7:38 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.