a347807131 opened a new issue, #16840:
URL: https://github.com/apache/shardingsphere/issues/16840
## A issue caused when integrating shardingsphere witing springboot jpa.
i have choose sharding-jdbc-core 4.1.0 to enble sharding tables, but i meet
a weired issuse.
when i was trying to update a entity date which had been selected with jpa
from sharding tables, jpa went to the table that was not the target according
to my sharding algorithm .
And i did some debug, then found jpd will do select operation on the entity
date according its primiary key before do the update operation ,so it did match
the sharding rule and went to the wrong table.
how could i resolve this ?please.
Many thanks.
##Here's the log
```log
Hibernate: select dicomimage0_.patientid as patienti1_0_0_,
dicomimage0_.seriesinstanceuid as seriesin2_0_0_, dicomimage0_.sopinstanceuid
as sopinsta3_0_0_, dicomimage0_.accesstime as accessti4_0_0_,
dicomimage0_.backupstatus as backupst5_0_0_, dicomimage0_.bodysite as
bodysite6_0_0_, dicomimage0_.cachedevicename as cachedev7_0_0_,
dicomimage0_.devicename as devicena8_0_0_, dicomimage0_.imagedate as
imagedat9_0_0_, dicomimage0_.imagelevel as imagele10_0_0_,
dicomimage0_.imagenumber as imagenu11_0_0_, dicomimage0_.imagetime as
imageti12_0_0_, dicomimage0_.imagewindow as imagewi13_0_0_,
dicomimage0_.keyimage as keyimag14_0_0_, dicomimage0_.labelxml as
labelxm15_0_0_, dicomimage0_.objectfile as objectf16_0_0_, dicomimage0_.site as
site17_0_0_, dicomimage0_.sopclassuid as sopclas18_0_0_, dicomimage0_.studydate
as studyda19_0_0_ from dicomimages dicomimage0_ where dicomimage0_.patientid=?
and dicomimage0_.seriesinstanceuid=? and dicomimage0_.sopinstanceuid=?
2022-04-14 23:45:41.981 INFO 16532 --- [ main] ShardingSphere-SQL
: Logic SQL: select dicomimage0_.patientid as
patienti1_0_0_, dicomimage0_.seriesinstanceuid as seriesin2_0_0_,
dicomimage0_.sopinstanceuid as sopinsta3_0_0_, dicomimage0_.accesstime as
accessti4_0_0_, dicomimage0_.backupstatus as backupst5_0_0_,
dicomimage0_.bodysite as bodysite6_0_0_, dicomimage0_.cachedevicename as
cachedev7_0_0_, dicomimage0_.devicename as devicena8_0_0_,
dicomimage0_.imagedate as imagedat9_0_0_, dicomimage0_.imagelevel as
imagele10_0_0_, dicomimage0_.imagenumber as imagenu11_0_0_,
dicomimage0_.imagetime as imageti12_0_0_, dicomimage0_.imagewindow as
imagewi13_0_0_, dicomimage0_.keyimage as keyimag14_0_0_, dicomimage0_.labelxml
as labelxm15_0_0_, dicomimage0_.objectfile as objectf16_0_0_, dicomimage0_.site
as site17_0_0_, dicomimage0_.sopclassuid as sopclas18_0_0_,
dicomimage0_.studydate as studyda19_0_0_ from dicomimages dicomimage0_ where
dicomimage0_.patientid
=? and dicomimage0_.seriesinstanceuid=? and dicomimage0_.sopinstanceuid=?
2022-04-14 23:45:41.981 INFO 16532 --- [ main] ShardingSphere-SQL
: SQLStatement:
SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@5e6d2502,
tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@26be5ee),
tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@26be5ee,
projectionsContext=ProjectionsContext(startIndex=7, stopIndex=823,
distinctRow=false, projections=[ColumnProjection(owner=dicomimage0_,
name=patientid, alias=Optional[patienti1_0_0_]),
ColumnProjection(owner=dicomimage0_, name=seriesinstanceuid,
alias=Optional[seriesin2_0_0_]), ColumnProjection(owner=dicomimage0_,
name=sopinstanceuid, alias=Optional[sopinsta3_0_0_]),
ColumnProjection(owner=dicomimage0_, name=accesstime,
alias=Optional[accessti4_0_0_]), ColumnProjection(owner=dicomimage0_,
name=backupstatus, alias=Optional[backupst5_0_
0_]), ColumnProjection(owner=dicomimage0_, name=bodysite,
alias=Optional[bodysite6_0_0_]), ColumnProjection(owner=dicomimage0_,
name=cachedevicename, alias=Optional[cachedev7_0_0_]),
ColumnProjection(owner=dicomimage0_, name=devicename,
alias=Optional[devicena8_0_0_]), ColumnProjection(owner=dicomimage0_,
name=imagedate, alias=Optional[imagedat9_0_0_]),
ColumnProjection(owner=dicomimage0_, name=imagelevel,
alias=Optional[imagele10_0_0_]), ColumnProjection(owner=dicomimage0_,
name=imagenumber, alias=Optional[imagenu11_0_0_]),
ColumnProjection(owner=dicomimage0_, name=imagetime,
alias=Optional[imageti12_0_0_]), ColumnProjection(owner=dicomimage0_,
name=imagewindow, alias=Optional[imagewi13_0_0_]),
ColumnProjection(owner=dicomimage0_, name=keyimage,
alias=Optional[keyimag14_0_0_]), ColumnProjection(owner=dicomimage0_,
name=labelxml, alias=Optional[labelxm15_0_0_]),
ColumnProjection(owner=dicomimage0_, name=objectfile,
alias=Optional[objectf16_0_0_]), ColumnProjection(owner=dicomimage0_
, name=site, alias=Optional[site17_0_0_]),
ColumnProjection(owner=dicomimage0_, name=sopclassuid,
alias=Optional[sopclas18_0_0_]), ColumnProjection(owner=dicomimage0_,
name=studydate, alias=Optional[studyda19_0_0_])]),
groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@6845dfcc,
orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@5415ed48,
paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@636787fd,
containsSubquery=false)
2022-04-14 23:45:41.982 INFO 16532 --- [ main] ShardingSphere-SQL
: Actual SQL: pacs ::: select dicomimage0_.patientid as
patienti1_0_0_, dicomimage0_.seriesinstanceuid as seriesin2_0_0_,
dicomimage0_.sopinstanceuid as sopinsta3_0_0_, dicomimage0_.accesstime as
accessti4_0_0_, dicomimage0_.backupstatus as backupst5_0_0_,
dicomimage0_.bodysite as bodysite6_0_0_, dicomimage0_.cachedevicename as
cachedev7_0_0_, dicomimage0_.devicename as devicena8_0_0_,
dicomimage0_.imagedate as imagedat9_0_0_, dicomimage0_.imagelevel as
imagele10_0_0_, dicomimage0_.imagenumber as imagenu11_0_0_,
dicomimage0_.imagetime as imageti12_0_0_, dicomimage0_.imagewindow as
imagewi13_0_0_, dicomimage0_.keyimage as keyimag14_0_0_, dicomimage0_.labelxml
as labelxm15_0_0_, dicomimage0_.objectfile as objectf16_0_0_, dicomimage0_.site
as site17_0_0_, dicomimage0_.sopclassuid as sopclas18_0_0_,
dicomimage0_.studydate as studyda19_0_0_ from dicomimages dicomimage0_ where
dicomimage0_
.patientid=? and dicomimage0_.seriesinstanceuid=? and
dicomimage0_.sopinstanceuid=? ::: [20211012002,
1.2.826.0.1.3680043.2.1545.1.2.1.7.20211012.151659.556.8,
1.3.12.2.1107.5.2.19.145147.2018053110565734467524245]
Hibernate: insert into dicomimages (accesstime, backupstatus, bodysite,
cachedevicename, devicename, imagedate, imagelevel, imagenumber, imagetime,
imagewindow, keyimage, labelxml, objectfile, site, sopclassuid, studydate,
patientid, seriesinstanceuid, sopinstanceuid) values (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
availableTargetNames:[dicomimages]
2022-04-14 23:45:42.027 INFO 16532 --- [ main] ShardingSphere-SQL
: Logic SQL: insert into dicomimages (accesstime,
backupstatus, bodysite, cachedevicename, devicename, imagedate, imagelevel,
imagenumber, imagetime, imagewindow, keyimage, labelxml, objectfile, site,
sopclassuid, studydate, patientid, seriesinstanceuid, sopinstanceuid) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2022-04-14 23:45:42.027 INFO 16532 --- [ main] ShardingSphere-SQL
: SQLStatement:
InsertStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement@7d5b1446,
tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6870f52a),
tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@6870f52a,
columnNames=[accesstime, backupstatus, bodysite, cachedevicename, devicename,
imagedate, imagelevel, imagenumber, imagetime, imagewindow, keyimage, labelxml,
objectfile, site, sopclassuid, studydate, patientid, seriesinstanceuid,
sopinstanceuid], insertValueContexts=[InsertValueContext(parametersCount=19,
valueExpressions=[ParameterMarkerExpressionSegment(startIndex=266,
stopIndex=266, parameterMarkerIndex=0),
ParameterMarkerExpressionSegment(startIndex=269, stopIndex=269,
parameterMarkerIndex=1), ParameterMarkerExpressionSegment(st
artIndex=272, stopIndex=272, parameterMarkerIndex=2),
ParameterMarkerExpressionSegment(startIndex=275, stopIndex=275,
parameterMarkerIndex=3), ParameterMarkerExpressionSegment(startIndex=278,
stopIndex=278, parameterMarkerIndex=4),
ParameterMarkerExpressionSegment(startIndex=281, stopIndex=281,
parameterMarkerIndex=5), ParameterMarkerExpressionSegment(startIndex=284,
stopIndex=284, parameterMarkerIndex=6),
ParameterMarkerExpressionSegment(startIndex=287, stopIndex=287,
parameterMarkerIndex=7), ParameterMarkerExpressionSegment(startIndex=290,
stopIndex=290, parameterMarkerIndex=8),
ParameterMarkerExpressionSegment(startIndex=293, stopIndex=293,
parameterMarkerIndex=9), ParameterMarkerExpressionSegment(startIndex=296,
stopIndex=296, parameterMarkerIndex=10),
ParameterMarkerExpressionSegment(startIndex=299, stopIndex=299,
parameterMarkerIndex=11), ParameterMarkerExpressionSegment(startIndex=302,
stopIndex=302, parameterMarkerIndex=12),
ParameterMarkerExpressionSegment(startIndex=305, s
topIndex=305, parameterMarkerIndex=13),
ParameterMarkerExpressionSegment(startIndex=308, stopIndex=308,
parameterMarkerIndex=14), ParameterMarkerExpressionSegment(startIndex=311,
stopIndex=311, parameterMarkerIndex=15),
ParameterMarkerExpressionSegment(startIndex=314, stopIndex=314,
parameterMarkerIndex=16), ParameterMarkerExpressionSegment(startIndex=317,
stopIndex=317, parameterMarkerIndex=17),
ParameterMarkerExpressionSegment(startIndex=320, stopIndex=320,
parameterMarkerIndex=18)], parameters=[20211012.000000000000000000000000000000,
NONE, 123, , HD3, 20180531, null, 0175, 105657.673000, null, null, null,
//20211012002/20211012002001/4/1.3.12.2.1107.5.2.19.145147.2018053110565734467524245.dcm,
750, 1.2.840.10008.5.1.4.1.1.4, 20211012, 20211012002,
1.2.826.0.1.3680043.2.1545.1.2.1.7.20211012.151659.556.8,
1.3.12.2.1107.5.2.19.145147.2018053110565734467524245])],
generatedKeyContext=Optional.empty)
2022-04-14 23:45:42.029 INFO 16532 --- [ main] ShardingSphere-SQL
: Actual SQL: pacs ::: insert into dicomimages_202110_750
(accesstime, backupstatus, bodysite, cachedevicename, devicename, imagedate,
imagelevel, imagenumber, imagetime, imagewindow, keyimage, labelxml,
objectfile, site, sopclassuid, studydate, patientid, seriesinstanceuid,
sopinstanceuid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?) ::: [20211012.000000000000000000000000000000, NONE, 123, , HD3, 20180531,
null, 0175, 105657.673000, null, null, null,
//20211012002/20211012002001/4/1.3.12.2.1107.5.2.19.145147.2018053110565734467524245.dcm,
750, 1.2.840.10008.5.1.4.1.1.4, 20211012, 20211012002,
1.2.826.0.1.3680043.2.1545.1.2.1.7.20211012.151659.556.8,
1.3.12.2.1107.5.2.19.145147.2018053110565734467524245]
2022-04-14 23:45:42.040 WARN 16532 --- [ main]
o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1062, SQLState: 23000
2022-04-14 23:45:42.040 ERROR 16532 --- [ main]
o.h.engine.jdbc.spi.SqlExceptionHelper : Duplicate entry
'1.3.12.2.1107.5.2.19.145147.2018053110565734467524245-1.2.826.0.' for key
'PRIMARY'
```
--
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.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]