Giter Site home page Giter Site logo

Comments (7)

dongoewang avatar dongoewang commented on June 12, 2024 2

from shardingsphere.

dongoewang avatar dongoewang commented on June 12, 2024

where should i start from?

from shardingsphere.

RaigorJiang avatar RaigorJiang commented on June 12, 2024

Hi, could you please provide your insert sql?

from shardingsphere.

dongoewang avatar dongoewang commented on June 12, 2024

Hi, could you please provide your insert sql?
thanks for replying。

i have been using saveBatch ofmybatis plus to insert data,such as 【clockRecordService.saveBatch(records)】。printed sql is following:
Logic SQL : INSERT INTO kq_employee_clock_record (
id,
employee_id,
clock_time,
clock_day,
clock_day_time,
longitude,
latitude,
address,
source,
os,
browser,
create_dt,
create_user,
update_dt,
update_user
)
VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
2024-03-08 13 : 23 : 28 [ INFO ] [ XNIO - 1 task - 1 ] ShardingSphere - SQL : < 0.1 >< ziti918130105703170048 > Actual SQL : datasource ::: INSERT INTO kq_employee_clock_record_202402 (
id,
employee_id,
clock_time,
clock_day,
clock_day_time,
longitude,
latitude,
address,
source,
os,
browser,
create_dt,
create_user,
update_dt,
update_user
)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ::: [ NULL,
65256,
2024-02-01 00 : 00 : 00.0,
2024-02-01,
00 : 00 : 00,
118.787651,
32.035561,
**建设银行江苏省分行秦淮洪武路 188号,
2,
win11,
Chrome Mobile,
2024-03-08 13 : 22 : 46.416,
NULL,
NULL,
NULL ]

testting sample is following
` public void testGenerator() throws Exception {
List records = new ArrayList<>(3);
EmployeeClockRecord clockRecord1 = new EmployeeClockRecord();
clockRecord1.setEmployeeId(65256L);
clockRecord1.setLongitude(new Double("118.787651"));
clockRecord1.setLatitude(new Double("32.035561"));
Date date = DateUtils.formatStringByStyleToDate("2024-01-31 15:08:40", "yyyy-MM-dd");
clockRecord1.setClockTime(date);
clockRecord1.setClockDay(DateUtils.formatDateByStyle(clockRecord1.getClockTime(), YYYY_MM_DD));
clockRecord1.setClockDayTime(DateUtils.formatDateByStyle(clockRecord1.getClockTime(), HH_MM_SS));
clockRecord1.setSource(2);
clockRecord1.setOs("win11");
clockRecord1.setBrowser("Chrome Mobile");
clockRecord1.setAddress("**建设银行江苏省分行秦淮洪武路188号");

    EmployeeClockRecord clockRecord2 = new EmployeeClockRecord();
    clockRecord2.setEmployeeId(65256L);
    clockRecord2.setLongitude(new Double("118.787651"));
    clockRecord2.setLatitude(new Double("32.035561"));
    Date date2 = DateUtils.formatStringByStyleToDate("2024-02-01 15:08:40", "yyyy-MM-dd");

// Date date2 = Date.from(localDate2.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
clockRecord2.setClockTime(date2);
clockRecord2.setClockDay(DateUtils.formatDateByStyle(clockRecord2.getClockTime(), YYYY_MM_DD));
clockRecord2.setClockDayTime(DateUtils.formatDateByStyle(clockRecord1.getClockTime(), HH_MM_SS));
clockRecord2.setSource(2);
clockRecord2.setOs("win11");
clockRecord2.setBrowser("Chrome Mobile");
clockRecord2.setAddress("**建设银行江苏省分行秦淮洪武路188号");

    records.add(clockRecord1);
    records.add(clockRecord2);
    String shardingDataSource ="shardingDataSource";
    DynamicDataSourceContextHolder.setDataSourceType(shardingDataSource);
    clockRecordService.saveBatch(records);
}

`

from shardingsphere.

RaigorJiang avatar RaigorJiang commented on June 12, 2024

OK, I noticed that your insert SQL already contains the id column, so it will not be automatically generated and rewritten.

You can try not to include the id column in the insert statement, then ShardingSphere will generate the value for you and rewrite the insert SQL.

from shardingsphere.

dongoewang avatar dongoewang commented on June 12, 2024

thanks,According to explanation,sovled the problem

from shardingsphere.

RaigorJiang avatar RaigorJiang commented on June 12, 2024

Great, happy for you!

from shardingsphere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.