This commit is contained in:
zyyang 2020-11-16 15:14:41 +08:00
parent 5454f092bf
commit 3ec1adf762
2 changed files with 5 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package com.taosdata.example.mybatisplusdemo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taosdata.example.mybatisplusdemo.domain.Temperature;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface TemperatureMapper extends BaseMapper<Temperature> {
@ -10,8 +11,8 @@ public interface TemperatureMapper extends BaseMapper<Temperature> {
@Update("CREATE TABLE if not exists temperature(ts timestamp, temperature float) tags(location nchar(64), tbIndex int)")
int createSuperTable();
@Update("create table #{tbName} using temperature tags( #{location} )")
int createTable(String tbName, String location);
@Update("create table #{tbName} using temperature tags( #{location}, #{tbIndex})")
int createTable(@Param("tbName") String tbName, @Param("location") String location, @Param("tbIndex") int tbIndex);
@Update("drop table if exists temperature")
void dropSuperTable();

View File

@ -28,11 +28,12 @@ public class TemperatureMapperTest {
@Before
public void before() {
mapper.dropSuperTable();
// create table temperature
mapper.createSuperTable();
// create table t_X using temperature
for (int i = 0; i < 10; i++) {
mapper.createTable("t_" + i, locations[random.nextInt(locations.length)]);
mapper.createTable("t_" + i, locations[random.nextInt(locations.length)], i);
}
// insert into table
int affectRows = 0;