本文整理汇总了Java中com.baomidou.mybatisplus.mapper.EntityWrapper.setSqlSelect方法的典型用法代码示例。如果您正苦于以下问题:Java EntityWrapper.setSqlSelect方法的具体用法?Java EntityWrapper.setSqlSelect怎么用?Java EntityWrapper.setSqlSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baomidou.mybatisplus.mapper.EntityWrapper
的用法示例。
在下文中一共展示了EntityWrapper.setSqlSelect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSqlSelect
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
/**
* 测试 sqlselect
*/
@Test
public void testSqlSelect() {
EntityWrapper entityWrapper = new EntityWrapper();
// entityWrapper.setSqlSelect(Column.create().column("col").as("name"),null,Column.create(),Column.create().as("11"),Column.create().column("col"));
entityWrapper.setSqlSelect(Column.create().column("col").as("name"), null, Column.create(), Column.create().as("11"), Column.create().column("col"));
System.out.println(entityWrapper.getSqlSelect());
Assert.assertEquals("col AS name,col", entityWrapper.getSqlSelect());
}
示例2: testSelectSql4SelectMaps
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
@Test
public void testSelectSql4SelectMaps() {
EntityWrapper<H2User> ew = new EntityWrapper<>();
ew.setSqlSelect("test_id, test_type");
List<Map<String, Object>> list = userService.selectMaps(ew);
for (Map<String, Object> map : list) {
System.out.println(map);
Object obj = map.get("TEST_DATE");
if (obj != null) {
System.out.println("TEST_DATE.class" + obj.getClass().getName());
} else {
obj = map.get("test_date");
if (obj != null) {
System.out.println("test_date.class" + obj.getClass().getName());
} else {
obj = map.get("testDate");
if (obj != null) {
System.out.println("testDate.class" + obj.getClass().getName());
} else {
obj = map.get("TESTDATE");
if (obj != null) {
System.out.println("TESTDATE.class" + obj.getClass().getName());
} else {
obj = map.get("testdate");
if (obj != null) {
System.out.println("testdate.class" + obj.getClass().getName());
}
}
}
}
}
}
}
示例3: testSelectSqlNotMapping
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
@Test
public void testSelectSqlNotMapping() {
EntityWrapper<H2User> ew = new EntityWrapper<>();
ew.setSqlSelect("test_id, test_type");
List<H2User> list = userService.selectList(ew);
for (H2User u : list) {
System.out.println(JSONObject.toJSON(u));
Assert.assertNull("test_id is not null, but should not mapping to id", u.getId());
Assert.assertNotNull("test_type should be convert to testType", u.getTestType());
}
}
示例4: testEntityWrapperSelectSql
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
@Test
public void testEntityWrapperSelectSql() {
EntityWrapper<H2User> ew = new EntityWrapper<>();
ew.setSqlSelect("test_id as id, name, age");
List<H2User> list = userService.selectList(ew);
for (H2User u : list) {
Assert.assertNotNull(u.getId());
Assert.assertNotNull(u.getName());
Assert.assertNull(u.getPrice());
}
}
示例5: testSqlSelectStrings
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
/**
* 测试 sqlselect
*/
@Test
public void testSqlSelectStrings() {
EntityWrapper entityWrapper = new EntityWrapper();
entityWrapper.setSqlSelect("name", "age", "sex");
System.out.println(entityWrapper.getSqlSelect());
Assert.assertEquals("name,age,sex", entityWrapper.getSqlSelect());
}
示例6: testSqlSelect
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
/**
* 测试 sqlselect
*/
@Test
public void testSqlSelect() {
EntityWrapper entityWrapper = new EntityWrapper();
// entityWrapper.setSqlSelect(Column.create().column("col").as("name"),null,Column.create(),Column.create().as("11"),Column.create().column("col"));
entityWrapper.setSqlSelect(Column.create().column("col").as("name"), null, Column.create(), Column.create().as("11"), Column.create().column("col"));
System.out.println(entityWrapper.getSqlSelect());
Assert.assertNotNull("col AS name,col", entityWrapper.getSqlSelect());
}
示例7: testSqlSelectColumns
import com.baomidou.mybatisplus.mapper.EntityWrapper; //导入方法依赖的package包/类
/**
* 测试 sqlselect
*/
@Test
public void testSqlSelectColumns() {
EntityWrapper entityWrapper = new EntityWrapper();
Columns columns = Columns.create().column("name", "name1").column("age").column("sex", "sex1", false);
entityWrapper.setSqlSelect(columns);
System.out.println(entityWrapper.getSqlSelect());
Assert.assertEquals("name AS name1,age,sex AS sex1", entityWrapper.getSqlSelect());
}