thanks, it does help, but after changing
   <list name="instructions">
to
   <list name="instructions" inverse="true">

NH no longer set the order_no !!

do i need to set the order_no by myself?


On Aug 19, 8:04 pm, "Pete Appleton" <[email protected]>
wrote:
> Does changing
>         <list name="instructions" >
> to
>         <list name="instructions" inverse="true" >
> help?
>
>
>
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
>
> Behalf Of danda
> Sent: 19 August 2011 04:37
> To: nhusers
> Subject: [nhusers] Indexed entity move problem
>
> I have a entity Category which contain a list of Instruction with
> index column, when i try to move a Instruction to another Category, it
> just can't work!!
>
> Below is the mapping file, and when i move the Instruction to other
> Category, in the DB, i found that the target instruction and all
> Instruction with order_no larger then target Instruction's category_id
> and order_no is set to NULL, please help me out, thank you!
>
>   <class name="Category" table="Category">
>     <id name="category_id">
>       <column name="category_id" />
>       <generator class="native" />
>     </id>
>
>     <list name="instructions" >
>       <key column="category_id" />
>       <index column="order_no" />
>       <one-to-many class="Instruction"/>
>     </list>
>   </class>
>
>   <class name="Instruction" table="Instructions">
>     <id name="instruction_id">
>       <column name="instruction_id" />
>       <generator class="native" />
>     </id>
>
>     <!-- one-to-one mapping: Category -->
>     <many-to-one name="category"
>                  class="Category"
>                  column="category_id"
>                  cascade="all"
>     />
>   </class>
>
> and below is the VB.NET code:
>
>             target.category = Nothing
>             If (parent IsNot Nothing) Then
>                 parent.instructions.Remove(target)
>             End If
>             c.instructions.Add(target)
>             target.category = c
>
> here is the statement generate by NH:
>
> -- statement #1
> UPDATE Instructions
> SET    security_id = NULL /* @p0_0 */,
>        icon_id = 288 /* @p1_0 */,
>        category_id = 25 /* @p2_0 */,
>        title = '555' /* @p3_0 */,
>        detail = '555' /* @p4_0 */,
>        link = '555' /* @p5_0 */,
>        post_date = '2011-08-18T11:39:53.00' /* @p6_0 */,
>        post_by = 'EIMPRENSA\danda' /* @p7_0 */,
>        is_new = 1 /* @p8_0 */,
>        order_no = 2 /* @p9_0 */,
>        last_edit_by = 'EIMPRENSA\danda' /* @p10_0 */,
>        edit_date = '2011-08-18T11:40:53.00' /* @p11_0 */,
>        value_date = '2011-08-18T00:00:00.00' /* @p12_0 */,
>        return_date = '2035-12-31T00:00:00.00' /* @p13_0 */,
>        is_removed = -1 /* @p14_0 */
> WHERE  instruction_id = 26 /* @p15_0 */
>
> -- statement #2
> UPDATE Instructions
> SET    category_id = 25 /* @p0_0 */,
>        order_no = 0 /* @p1_0 */
> WHERE  instruction_id = 26 /* @p2_0 */
>
> -- statement #3
> UPDATE Instructions
> SET    category_id = null,
>        order_no = null
> WHERE  category_id = 7 /* @p0 */
>        AND instruction_id = 10 /* @p1 */
>
> -- statement #4
> UPDATE Instructions
> SET    category_id = null,
>        order_no = null
> WHERE  category_id = 7 /* @p0_0 */
>        AND instruction_id = 26 /* @p1_0 */
>
> UPDATE Instructions
> SET    category_id = null,
>        order_no = null
> WHERE  category_id = 7 /* @p0_1 */
>        AND instruction_id = 19 /* @p1_1 */
>
> -- statement #5
> ERROR:
> Batch update returned unexpected row count from update; actual row
> count: 1; expected: 2Could not synchronize database state with session
>
> --
> You received this message because you are subscribed to the Google
> Groups "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to