0 Replies Latest reply on May 13, 2010 5:35 AM by Amit Gadkari

    Data Modeling and cascade insert

    Amit Gadkari Level 1

      Is cascade insert possible using data modeling ?

      I am having very simple model

      Order with many LineItems.

      When I save Order, LineItems should also be saved in same transaction.

       

      If cascade is not supported then alternative way ?

       

      My suggestion which is very bad way of implementation.

      a) Insert Order

      b) Get generated OrderId. Insertion of order is asyn call. Hence have callback method which gets called after insertion of order.

      c) Loop through each lineitem and call insert for each lineitem (each insert of lineItem is also asyn call)

       

      Please let me know your suggestions

       

      My data model

       

      <model xmlns="http://ns.adobe.com/Fiber/1.0">

                      <annotation name="DMS">

                                      <item name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</item>

                                      <item name="datasource">java:/comp/env/jdbc/TestDB</item>

                      </annotation>

                      <annotation name="ActionScriptGeneration">

                                      <item name="LikeOperatorCaseSensitive">false</item>

                      </annotation>

                      <entity name="MaintainCustomerBean" persistent="true">

                                      <annotation name="VisualModeler" x="24" y="27" width="194" height="191"/>

                                      <annotation name="ServerProperties" ServerType="LCDS"/>

                                      <annotation name="DMS" Table="customer" use-transactions="false"/>

                                      <annotation name="ActionScriptGeneration" Package="vo" ImplicitServicePackage="services"/>

                                      <id name="CustomerId" type="integer">

                                                      <annotation name="DMS" ColumnName="CustomerId"/>

                                      </id>

                                      <property name="Name" type="string">

                                                      <annotation name="DMS" ColumnName="Name"/>

                                                      <annotation name="ActionScriptGeneration" DisableAutoReCalc="true"/>

                                      </property>

                      </entity>

                      <entity name="MaintainOrderBean" persistent="true">

                                      <annotation name="VisualModeler" width="226" height="126" x="471" y="30"/>

                                      <annotation name="ServerProperties" ServerType="LCDS"/>

                                      <annotation name="ActionScriptGeneration" Package="vo" ImplicitServicePackage="services"/>

                                      <annotation name="DMS" Table="orders" use-transactions="false"/>

                                      <property name="Name" type="string">

                                                      <annotation name="DMS" ColumnName="Name"/>

                                      </property>

                                      <id name="OrderId" type="integer" generated="false">

                                                      <annotation name="DMS" ColumnName="OrderId"/>

                                      </id>

                                      <property name="LineItemList" type="MaintainLineItem[]" mappedBy="orderBean">

                                                      <annotation name="DMS" lazy="false"/>

                                      </property>

                      </entity>

                      <entity name="MaintainItemBean" persistent="true">

                                      <annotation name="VisualModeler" width="115" height="94" x="39" y="316"/>

                                      <annotation name="ServerProperties" ServerType="LCDS"/>

                                      <annotation name="DMS" Table="items" use-transactions="false"/>

                                      <annotation name="ActionScriptGeneration" Package="vo" ImplicitServicePackage="services"/>

                                      <id name="ItemId" type="integer">

                                                      <annotation name="DMS" ColumnName="ItemId"/>

                                      </id>

                                      <property name="Name" type="string">

                                                      <annotation name="DMS" ColumnName="Name"/>

                                      </property>

                                      <property name="Price" type="float">

                                                      <annotation name="DMS" ColumnName="Price"/>

                                      </property>

                                      <property name="LineItemList" type="MaintainLineItem[]" mappedBy="itemBean">

                                                      <annotation name="DMS" lazy="true"/>

                                      </property>

                      </entity>

                      <entity name="MaintainLineItem" persistent="true">

                                      <annotation name="VisualModeler" width="115" height="110" x="272" y="65"/>

                                      <annotation name="ServerProperties" ServerType="LCDS"/>

                                      <annotation name="DMS" use-transactions="false" Table="LineItem"/>

                                      <annotation name="ActionScriptGeneration" Package="vo" ImplicitServicePackage="services"/>

                                      <annotation name="JavaGeneration" Package="com.deere" GenerateAssembler="true" AssemblerPackage="com.assembler"/>

                                      <property name="Quantity" type="float">

                                                      <annotation name="DMS" ColumnName="Quantity"/>

                                      </property>

                                      <property name="orderBean" type="MaintainOrderBean" required="true">

                                                      <annotation name="DMS" JoinColumns="OrderId"/>

                                      </property>

                                      <property name="itemBean" type="MaintainItemBean" required="true">

                                                      <annotation name="DMS" JoinColumns="ItemId" lazy="false"/>

                                      </property>

                                      <id name="orderId" type="integer" generated="false">

                                                      <annotation name="DMS" ColumnName="OrderId"/>

                                      </id>

                                      <id name="ItemId" type="integer" generated="false">

                                                      <annotation name="DMS" ColumnName="ItemId"/>

                                      </id>

                      </entity>

      </model>