Skip to content

Lazy loading should not be triggered by setter methods #749

@viruscamp

Description

@viruscamp

Feature request

Please add setting that let lazyLoader not to be triggered by setter methods

    <settings>
        <setting name="cacheEnabled" value="true" />
        <setting name="lazyLoadingEnabled" value="true" />
        <setting name="aggressiveLazyLoading" value="false" />
        <setting name="lazyLoadTriggerMethods" value="" />
    </settings>
// model
public class User {
  long id;
  List<Role> roles;
  List<Role> getRoles() { return roles; }
  void setRoles(List<Role> roles) { this.roles = roles; }
}

// call mapper
u1 = userMapper.selectByPrimaryKey(1l);
u1.getRoles(); // this trigger a lazy load query successful

u1 = userMapper.selectByPrimaryKey(2l);
u2.setRoles(new ArrayList<Role>()); // this also trigger a lazy load query which I donot want

I wanna a setting let the setRoles method not to trigger the lazy load query.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions