For every entity we do have a Mapper. Below mentioned PolicyMap has 
Entity called Policy. 

 

    public class PolicyMap : ClassMap<Policy>

    {          

        public PolicyMap()

        {

            Table("POLICY");

            LazyLoad();

            DynamicUpdate();

            SelectBeforeUpdate();            

            Id(x => 
x.PolicyId).Column("POLICY").GeneratedBy.Sequence("SEQ_POLICY");

            References(x => x.PolicyPrefix).Column("POLICY_PREFIX");

     Map(x => x.Umbrella).Column("UMBRELLA");

         } 

     }

 

*Issue :*

When we are trying to update single “Umbrella” Column it is updating the 
entire Policy(i.e. Remaining  Policy  columns are updating as null).

 

*Approach 1:*

After goggling we found NHibernate out of the box options called 
  DdynamicUpdate() and SelectBeforeUpdate()  whenever you are updating and 
it has to applied  @ Mapper level ,we applied this approach but it is still 
updating entire Policy entity.

 

*Approach 2:*

public class PolicyMap : ClassMap<Policy>

    {  

        public PolicyMap()

        {

            Table("POLICY");

            LazyLoad();        

            Id(x => x.PolicyId).Column("POLICY").GeneratedBy.Sequence(
"SEQ_POLICY");

            References(x => x.PolicyPrefix).Column("POLICY_PREFIX");

            Map(x => x.Umbrella).Column("UMBRELLA");

            Map(x => x.AgencyCode).Column("AGENCY_CODE").Not.Update();

                 }

       }

On more NHibernate Out of the feature is Not.Update().when applied this 
option to any of the mapper column(i.e. which we don’t want to update) it 
is stopped updating that column into DB.

 

*Issue with this approach2  :*

  Policy Mapper is used in may scenarios.

 

Scenario 1:

  As part of Endorsement we are updating Admin Data ,in Admin Data we are 
updating Umbrella Column from Policy Entity, Hence we applied 
Approach2(i..except Umbrella We applied Not.Update() to remaining columns) 
it is working fine(i.e. Updating only Umbrella column and rest of the 
column data is unchanged). 

 

But Same Policy Mapper will be used in Updating Endorsement(i.e. Issuing EN 
Transaction) ,the problem here is all columns are mapper with Not.Update() 
,but we want to update some of the fields as part of EN transaction.

 

We want to know the Out of the box feature of NHibernate to support/Update 
only those columns which Modified. If you need any clarify please do call 
me.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/kPke_Oorx5YJ.
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