1

I have a function which reads all data from my database, make some changes and return a list of data. But when I make changes in entity's field, all related data changes too. Code will explain better.

List<ICmsExemptRestrictDet> models = DAOLocator.getCmsExemptRestrictDetDAO().findByDefinitionId(definitionId);

for(ICmsExemptRestrictDet model : models){
        if(CmsExemptionParameterConstants.ParameterTypeOfDetail.EXPONENTIAL_CODE.toString().equals(model.getParameterType())){
            String exponentialCode = model.getParameterValue();
            String exponentialName = //some data
            model.setParameterValue(exponentialName.concat(" : ").concat(exponentialCode));
        }
}

At the beginning, database has 3 data such as

  • 0100
  • 0200
  • 0300

When my code runs, they becomes

  • BlaBla : 0100
  • BlaBla2 : 0200
  • HelloWorld : 0300

Neither I trigger update method of my repository nor insert. I dont know how it effect my database.

Thanks

Berkin
  • 1,565
  • 5
  • 22
  • 48
  • 2
    That is the nature of a managed entity. Hibernate detects changes and when in an active transaction/session it will automatically syncronize changes with the database. – M. Deinum Jun 13 '19 at 07:00

0 Answers0