Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryWrapper/LambdaQueryWrapper中调用super.initNeed(),无法调用子类方法 #5914

Open
chess3cake opened this issue Jan 9, 2024 · 2 comments

Comments

@chess3cake
Copy link

chess3cake commented Jan 9, 2024

当前使用版本(必填,否则不予处理)

3.5.5

该问题是如何引起的?(确定最新版也有问题再提!!!)

QueryWrapper/LambdaQueryWrapper中调用super.initNeed(),无法调用子类方法

image

image

重现步骤(如果有就写完整)

报错信息

期望

期望是调用this.initNeed()/setEntity(),这样可以允许调用子类方法

@miemieYaho
Copy link
Member

你为什么要重写这两个方法?

@chess3cake
Copy link
Author

chess3cake commented Jan 9, 2024

@miemieYaho
entity的代码如下

@Data
@TableName(value = "test", autoResultMap = true)
public class TestEntity  {
    private String companyName;
}

调用代码如下

TestEntity projectEntity = new TestEntity();
projectEntity.setCompanyName("123");
QueryWrapper<TestEntity> wrapper = Wrappers.query(projectEntity);
wrapper.eq("COMPANY_NAME", "12345");
List<TestEntity> testEntities = testMapper.selectList(wrapper);

生成的sql语句如下

SELECT COMPANY_NAME FROM test WHERE COMPANY_NAME=? AND (COMPANY_NAME = ?)

我希望能够通过自定义wrapper达到wrapper.eq的条件能够覆盖entity自动生成的条件

预期sql为

SELECT COMPANY_NAME FROM test WHERE COMPANY_NAME=?)

且COMPANY_NAME对应的value为eq中设置的value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants