3.0.5

正常使用insert插入

重现步骤

实体对象有tenantId属性

报错信息

INSERT INTO cb_student (id, tenant_id, name, assign_type, tenant_id) VALUES (?, ?, ?, ?, 1) ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Column 'tenant_id' specified twice

Comment From: dunkboy

我好像找到问题出在哪里了,但是不知道具体原因是什么?麻烦能告诉我具体原因吗? MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); //设置分页 bean.setPlugins(new Interceptor[]{paginationInterceptor()});//我注释掉了就没有问题了paginationInterceptor()是返回分页对象里面包含了租户的处理

Comment From: dunkboy

我发现我注释了bean.setPlugins(new Interceptor[]{paginationInterceptor()});这行代码后 分页就失效了 但是如果不注释insert插入就会多出tenant_id来

Comment From: miemieYaho

多租户设计上就是不需要entity里写租户字段,把你entity的租户字段删除即可

Comment From: dunkboy

不是实体里面有租户字段的问题,是我自己搞错了,插入的时候租户字段不能再赋值了!!!

Comment From: miemieYaho

租户信息是插件自动强加上去的.实体类里不需要

Comment From: chunlaiqingke

那如果query的时候tenantId怎么拿出来呢