ソースを参照

fixed gitee issues/IL0B2

hubin 7 年 前
コミット
8ad8e28b46

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java

@@ -222,7 +222,7 @@ public abstract class AbstractMethod {
                 if (table.isKeyRelated()) {
                     columns.append(table.getKeyColumn()).append(" AS ").append(sqlWordConvert(table.getKeyProperty()));
                 } else {
-                    columns.append(sqlWordConvert(table.getKeyProperty()));
+                    columns.append(sqlWordConvert(table.getKeyColumn()));
                 }
                 if (size >= 1) {
                     // 判断其余字段是否存在

+ 3 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserMapperTest.java

@@ -55,10 +55,10 @@ public class H2UserMapperTest extends BaseTest {
         h2User.setDesc("这是一个不错的小伙子");
         Assert.assertTrue(1 == userMapper.insert(h2User));
 
-        log(h2User.getId());
+        log(h2User.getTestId());
 
         // 新增一条自定义 ID = 1 的测试删除数据
-        h2User.setId(1L);
+        h2User.setTestId(1L);
         h2User.setName("测试");
         userMapper.insert(h2User);
         for (int i = 0; i < 10; i++) {
@@ -90,7 +90,7 @@ public class H2UserMapperTest extends BaseTest {
 
         // 批量删除
         Assert.assertTrue(count == userMapper.deleteBatchIds(h2UserList
-            .stream().map(u -> u.getId()).collect(toList())));
+            .stream().map(u -> u.getTestId()).collect(toList())));
 
         // 更新
         h2User = new H2User();

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java

@@ -69,7 +69,7 @@ public class H2UserTest extends BaseTest {
         ew.select("test_id as id, name, age");
         List<H2User> list = userService.selectList(ew);
         for (H2User u : list) {
-            Assert.assertNotNull(u.getId());
+            Assert.assertNotNull(u.getTestId());
             Assert.assertNotNull(u.getName());
             Assert.assertNull(u.getPrice());
         }
@@ -86,7 +86,7 @@ public class H2UserTest extends BaseTest {
         Assert.assertNotNull(list);
         for (H2User u : list) {
             Assert.assertEquals(nameParam, u.getName());
-            Assert.assertNotNull(u.getId());
+            Assert.assertNotNull(u.getTestId());
         }
     }
 

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/entity/SuperEntity.java

@@ -35,8 +35,8 @@ import lombok.experimental.Accessors;
 public class SuperEntity extends SuSuperEntity implements Serializable {
 
     /* 主键ID 注解,value 字段名,type 用户输入ID */
-    @TableId(value = "test_id")
-    private Long id;
+    @TableId
+    private Long testId;
 
 }
 

+ 3 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/entity/persistent/H2User.java

@@ -83,17 +83,17 @@ public class H2User extends SuperEntity {
     }
 
     public H2User(Long id, String name) {
-        this.setId(id);
+        this.setTestId(id);
         this.name = name;
     }
 
     public H2User(Long id, Integer age) {
-        this.setId(id);
+        this.setTestId(id);
         this.age = age;
     }
 
     public H2User(Long id, String name, Integer age, Integer testType) {
-        this.setId(id);
+        this.setTestId(id);
         this.name = name;
         this.age = age;
         this.testType = testType;