[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521206752 Other solution, I think, is add where clause with sharding column to query SQL, it can route SQL to actual node and find data. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521205179 It can config as groovy program, like `ds0.t_order_${0..100}_${201901..201912}`, it means t_order_0_201901, t_order_0_201902 . t_order_100_ 201911, t_order_100_201912. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521196220 From your example code, I find you do not config `actual_node`, it will cause can not find data with full-routing. After add `spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds0.t_order_100_201908`, the problem solved. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521184790 > It turns out that the saveAll method changed nothing which also is a problem. It looks like other problem, please open a new issue to describe it. Thanks. > but not reproduce my situation. Please tell me **related information which can reproduce the problem about this issue**. BTW, the link your provide only has a `README.md` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521158818 Sorry, I don't have full time to talk privately, I suggest you provide a the simplest example code without your business information or full configuration/entity,repo/SQL. We will reply after reproducing and finding the reason. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521153242 I don't know, the information you provide is so isolation, I can't locate where or what problem caused. 1. What's your sharding configuration? 2. What's your logic SQL? 3. What's the actual SQL after shardingsphere rewrite? 4. Primary is auto increment ID, Make sure whether JPA/Hibernate cached the entity you select by ID. I suggest you provide enough information let us reproduce your problem, or example code which can reproduce so that we can help you find the reason. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521130891 Of course, the stack is your application -> jpa -> sharding -> hikari pool -> origin jdbc This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521081996 My example code : https://github.com/KomachiSion/shardingsphere-issues/tree/master/issue2865 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521081656 @DongJigong, I try to reproduce your problem, but failed. I create a sharding table `t_order` with three column. configuration following: ``` spring.jpa.properties.hibernate.hbm2ddl.auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=true spring.shardingsphere.enabled=true spring.shardingsphere.datasource.names=ds0, ds1 spring.shardingsphere.datasource.ds0.type=org.apache.commons.dbcp2.BasicDataSource spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.jdbc.Driver spring.shardingsphere.datasource.ds0.url=jdbc:mysql://localhost:3306/demo_ds_0 spring.shardingsphere.datasource.ds0.username=root spring.shardingsphere.datasource.ds0.password= spring.shardingsphere.datasource.ds1.type=org.apache.commons.dbcp2.BasicDataSource spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver spring.shardingsphere.datasource.ds1.url=jdbc:mysql://localhost:3306/demo_ds_1 spring.shardingsphere.datasource.ds1.username=root spring.shardingsphere.datasource.ds1.password= spring.shardingsphere.sharding.default-data-source-name=ds0 spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{0..1} spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.sharding-column=id spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.algorithm-expression=ds$->{id % 2} spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_$->{order_id % 2} spring.shardingsphere.props.sql.show=true ``` Insert 24 row to `t_order` as init data. Then use `saveAll` to change column `status`: ``` OrderRepo repo = applicationContext.getBean(OrderRepo.class); List list = new ArrayList<>(); for (int i = 1; i <= 24; i++) { Order order = new Order(); order.setId(i); order.setOrderId(i); order.setStatus("TEST"); list.add(order); } repo.saveAll(list); ``` It can update, not insert new row: ``` Hibernate: select order0_.id as id1_0_0_, order0_.order_id as order_id2_0_0_, order0_.status as status3_0_0_ from t_order order0_ where order0_.id=? 2019-08-14 10:42:21.713 INFO 1581 --- [ main] ShardingSphere-SQL : Rule Type: sharding 2019-08-14 10:42:21.713 INFO 1581 --- [ main] ShardingSphere-SQL : Logic SQL: select order0_.id as id1_0_0_, order0_.order_id as order_id2_0_0_, order0_.status as status3_0_0_ from t_order order0_ where order0_.id=? 2019-08-14 10:42:21.713 INFO 1581 --- [ main] ShardingSphere-SQL : SQLStatement: ShardingSelectOptimizedStatement(tables=Tables(tables=[Table(name=t_order, alias=Optional.of(order0_))], schema=Optional.absent()), groupBy=org.apache.shardingsphere.core.optimize.sharding.segment.select.groupby.GroupBy@12214f2f, orderBy=org.apache.shardingsphere.core.optimize.sharding.segment.select.orderby.OrderBy@756c67cd, selectItems=SelectItems(startIndex=7, stopIndex=96, distinctRow=false, items=[ColumnSelectItem(owner=order0_, name=id, alias=Optional.of(id1_0_0_)), ColumnSelectItem(owner=order0_, name=order_id, alias=Optional.of(order_id2_0_0_)), ColumnSelectItem(owner=order0_, name=status, alias=Optional.of(status3_0_0_))], tables=[TableSegment(startIndex=103, stopIndex=109, name=t_order, quoteCharacter=NONE, owner=Optional.absent(), alias=Optional.of(order0_))]), pagination=org.apache.shardingsphere.core.optimize.sharding.segment.select.pagination.Pagination@50de907a, containsSubquery=false) 2019-08-14 10:42:21.713 INFO 1581 --- [ main] ShardingSphere-SQL : Actual SQL: ds0 ::: select order0_.id as id1_0_0_, order0_.order_id as order_id2_0_0_, order0_.status as status3_0_0_ from t_order_0 order0_ where order0_.id=? ::: [24] 2019-08-14 10:42:21.713 INFO 1581 --- [ main] ShardingSphere-SQL : Actual SQL: ds0 ::: select order0_.id as id1_0_0_, order0_.order_id as order_id2_0_0_, order0_.status as status3_0_0_ from t_order_1 order0_ where order0_.id=? ::: [24] ... Hibernate: update t_order set order_id=?, status=? where id=? 2019-08-14 10:42:22.158 INFO 1581 --- [ main] ShardingSphere-SQL : Rule
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521074125 > > OK, I will try to reproduce. > > ![image](https://user-images.githubusercontent.com/8855265/62989204-b0eaaa00-be79-11e9-9b0e-6060317188de.png) > This table has a complex column slices. All my descriptions depend on operating this table Can you provide full sharding configuration? I still think that if there is a example code will be better, which can avoid our meaningless intelligence exchange and improve efficiency. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521072640 OK, I will try to reproduce. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521070584 > I have tracked my code, I found sharding sql log show that sharding-jdbc will select one row with id and insert it. I have 24 rows data. sharding iterate 24 times. Sorry, I can't understand your situation accurately. You means that you have found the reason? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert
KomachiSion commented on issue #2865: 4.0.0-RC1 jpa select result change some values and save shoud update Row Data rather then insert URL: https://github.com/apache/incubator-shardingsphere/issues/2865#issuecomment-521067600 @DongJigong, can you provide a example code which can reproduce this issue? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services