Loading RELEASE-NOTES.md +3 −2 Original line number Diff line number Diff line ## 2.0.2 ### 功能提升 1. [ISSUE #475](https://github.com/shardingjdbc/sharding-jdbc/issues/475) 支持create index语句 1. [ISSUE #475](https://github.com/shardingjdbc/sharding-jdbc/issues/475) 支持CREATE INDEX 1. [ISSUE #525](https://github.com/shardingjdbc/sharding-jdbc/issues/525) 支持DROP INDEX ### 缺陷修正 1. [ISSUE #520](https://github.com/shardingjdbc/sharding-jdbc/issues/520) 引入分表后,唯一键冲突时异常类型不再是DuplicateKeyException Loading sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/java/io/shardingjdbc/spring/namespace/constants/ShardingDataSourceBeanDefinitionParserTag.java +2 −0 Original line number Diff line number Diff line Loading @@ -67,4 +67,6 @@ public final class ShardingDataSourceBeanDefinitionParserTag { public static final String COLUMN_KEY_GENERATOR_CLASS = "column-key-generator-class"; public static final String KEY_GENERATOR_CLASS = "key-generator-class"; public static final String LOGIC_INDEX = "logic-index"; } sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/java/io/shardingjdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java +4 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,10 @@ public class ShardingDataSourceBeanDefinitionParser extends AbstractBeanDefiniti if (!Strings.isNullOrEmpty(keyGeneratorClass)) { factory.addPropertyValue("keyGeneratorClass", keyGeneratorClass); } String logicIndex = tableElement.getAttribute(ShardingDataSourceBeanDefinitionParserTag.LOGIC_INDEX); if (!Strings.isNullOrEmpty(logicIndex)) { factory.addPropertyValue("logicIndex", logicIndex); } return factory.getBeanDefinition(); } Loading sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ <xsd:attribute name="table-strategy-ref" type="xsd:string" use="optional" /> <xsd:attribute name="generate-key-column" type="xsd:string" use="optional" /> <xsd:attribute name="column-key-generator-class" type="xsd:string" use="optional"/> <xsd:attribute name="logic-index" type="xsd:string" use="optional" /> </xsd:complexType> </xsd:element> <xsd:element name="binding-table-rules"> Loading sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/test/java/io/shardingjdbc/spring/cases/WithNamespaceLogicIndexTest.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright 1999-2015 dangdang.com. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </p> */ package io.shardingjdbc.spring.cases; import io.shardingjdbc.spring.AbstractShardingBothDataBasesAndTablesSpringDBUnitTest; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @ContextConfiguration(locations = "classpath:META-INF/rdb/withNamespaceLogicIndex.xml") public final class WithNamespaceLogicIndexTest extends AbstractShardingBothDataBasesAndTablesSpringDBUnitTest { @Test public void assertIndex() throws SQLException { try (Connection connection = getShardingDataSource().getConnection()) { String sql = "CREATE INDEX t_order_index ON t_order(user_id)"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.execute(); sql = "DROP INDEX t_order_index"; preparedStatement = connection.prepareStatement(sql); preparedStatement.execute(); preparedStatement.close(); } } } Loading
RELEASE-NOTES.md +3 −2 Original line number Diff line number Diff line ## 2.0.2 ### 功能提升 1. [ISSUE #475](https://github.com/shardingjdbc/sharding-jdbc/issues/475) 支持create index语句 1. [ISSUE #475](https://github.com/shardingjdbc/sharding-jdbc/issues/475) 支持CREATE INDEX 1. [ISSUE #525](https://github.com/shardingjdbc/sharding-jdbc/issues/525) 支持DROP INDEX ### 缺陷修正 1. [ISSUE #520](https://github.com/shardingjdbc/sharding-jdbc/issues/520) 引入分表后,唯一键冲突时异常类型不再是DuplicateKeyException Loading
sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/java/io/shardingjdbc/spring/namespace/constants/ShardingDataSourceBeanDefinitionParserTag.java +2 −0 Original line number Diff line number Diff line Loading @@ -67,4 +67,6 @@ public final class ShardingDataSourceBeanDefinitionParserTag { public static final String COLUMN_KEY_GENERATOR_CLASS = "column-key-generator-class"; public static final String KEY_GENERATOR_CLASS = "key-generator-class"; public static final String LOGIC_INDEX = "logic-index"; }
sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/java/io/shardingjdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java +4 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,10 @@ public class ShardingDataSourceBeanDefinitionParser extends AbstractBeanDefiniti if (!Strings.isNullOrEmpty(keyGeneratorClass)) { factory.addPropertyValue("keyGeneratorClass", keyGeneratorClass); } String logicIndex = tableElement.getAttribute(ShardingDataSourceBeanDefinitionParserTag.LOGIC_INDEX); if (!Strings.isNullOrEmpty(logicIndex)) { factory.addPropertyValue("logicIndex", logicIndex); } return factory.getBeanDefinition(); } Loading
sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ <xsd:attribute name="table-strategy-ref" type="xsd:string" use="optional" /> <xsd:attribute name="generate-key-column" type="xsd:string" use="optional" /> <xsd:attribute name="column-key-generator-class" type="xsd:string" use="optional"/> <xsd:attribute name="logic-index" type="xsd:string" use="optional" /> </xsd:complexType> </xsd:element> <xsd:element name="binding-table-rules"> Loading
sharding-jdbc-core-spring/sharding-jdbc-core-spring-namespace/src/test/java/io/shardingjdbc/spring/cases/WithNamespaceLogicIndexTest.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright 1999-2015 dangdang.com. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </p> */ package io.shardingjdbc.spring.cases; import io.shardingjdbc.spring.AbstractShardingBothDataBasesAndTablesSpringDBUnitTest; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @ContextConfiguration(locations = "classpath:META-INF/rdb/withNamespaceLogicIndex.xml") public final class WithNamespaceLogicIndexTest extends AbstractShardingBothDataBasesAndTablesSpringDBUnitTest { @Test public void assertIndex() throws SQLException { try (Connection connection = getShardingDataSource().getConnection()) { String sql = "CREATE INDEX t_order_index ON t_order(user_id)"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.execute(); sql = "DROP INDEX t_order_index"; preparedStatement = connection.prepareStatement(sql); preparedStatement.execute(); preparedStatement.close(); } } }