0

I have a method annotated with @Transactional in a Service. I retrieve an object from my DB. After the method annotated with @Transactional end, change a field with one set in the Action (after call the Service), and not save the object, but the database gets updated. Save in the database after the transaction end. Every set in the entity save in the database after the method end. Why?

In the Action:

public String showClientFileInformationDetail() {
    ...
    assetType = (ArrayList<AssetType>) ServiceAssetType.getAssetsType(client.getPersonType(),null);
    for (AssetType elem : assetType) {                  
        elem.setAssetTypeName("prueba ejemplo");
    ...
}

The Service Impl:

@Transactional
@Service
public class AssetTypeServiceImpl implements AssetTypeService {
    @Autowired
    private AssetTypeDao assetTypeDao;

    public AssetTypeServiceImpl() { }

    public List<AssetType> getAssetsType(Character assetClientType, String assetClientTypeClasification,
        Character status, Integer pageNumber, Integer pageSize, String orderBy) {
        return (List<AssetType>)assetTypeDao.getAssetsType( assetClientType,  assetClientTypeClasification, status,  pageNumber,  pageSize,  orderBy);      
    }
}

The Service:

@Service
public interface AssetTypeService {
    public List<AssetType> getAssetsType(Character assetClientType, String assetClientTypeClasification, Character status, Integer pageNumber, Integer pageSize, String orderBy);
}
budi
  • 6,351
  • 10
  • 55
  • 80

0 Answers0