Search in sources :

Example 1 with Course

use of com.roy.shardingDemo.entity.Course in project code by lastwhispers.

the class ShardingJDBCTest method queryCourse.

@Test
public void queryCourse() {
    // select * from course
    QueryWrapper<Course> wrapper = new QueryWrapper<>();
    wrapper.orderByDesc("cid");
    // wrapper.eq("cid",730100102537940992L);
    // wrapper.in("cid",730100102537940992L,730100102990925824L);
    List<Course> courses = courseMapper.selectList(wrapper);
    System.out.println("条数:" + courses.size());
    for (Course course : courses) {
        System.out.println("查询结果:" + course);
    }
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Course(com.roy.shardingDemo.entity.Course) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Course

use of com.roy.shardingDemo.entity.Course in project code by lastwhispers.

the class ShardingJDBCTest method addCourse.

@Test
public void addCourse() {
    for (int i = 0; i < 10; i++) {
        Course c = new Course();
        // c.setCid(Long.valueOf(i));
        c.setCname("shardingsphere");
        c.setUserId(Long.valueOf("" + (1000 + i)));
        c.setCstatus("1");
        courseMapper.insert(c);
    }
}
Also used : Course(com.roy.shardingDemo.entity.Course) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Course

use of com.roy.shardingDemo.entity.Course in project code by lastwhispers.

the class ShardingJDBCTest method queryCourseByHint.

@Test
public void queryCourseByHint() {
    HintManager hintManager = HintManager.getInstance();
    hintManager.addTableShardingValue("course", 2);
    List<Course> courses = courseMapper.selectList(null);
    courses.forEach(course -> System.out.println(course));
    hintManager.close();
}
Also used : HintManager(org.apache.shardingsphere.api.hint.HintManager) Course(com.roy.shardingDemo.entity.Course) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Course (com.roy.shardingDemo.entity.Course)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 HintManager (org.apache.shardingsphere.api.hint.HintManager)1