diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/PrimaryKeyType.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/PrimaryKeyType.java index ce40be882..6a729626a 100644 --- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/PrimaryKeyType.java +++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/PrimaryKeyType.java @@ -26,7 +26,7 @@ public enum PrimaryKeyType { /** * Used for a column that is part of the partition key. */ - PARTITION, + PARTITIONED, /** * Used for a column that is clustered key. diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGenerator.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGenerator.java index f1d19a9c7..9af43eeb9 100644 --- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGenerator.java +++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGenerator.java @@ -16,7 +16,7 @@ package org.springframework.cassandra.core.cql.generator; import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull; -import static org.springframework.cassandra.core.PrimaryKeyType.PARTITION; +import static org.springframework.cassandra.core.PrimaryKeyType.PARTITIONED; import static org.springframework.cassandra.core.PrimaryKeyType.CLUSTERED; import java.util.ArrayList; @@ -69,7 +69,7 @@ public class CreateTableCqlGenerator extends TableCqlGeneratornull. + * {@link #keyType} to {@link PrimaryKeyType#PARTITIONED} and its {@link #ordering} to null. * * @return this */ @@ -83,12 +84,12 @@ public class ColumnSpecification { /** * Toggles the identification of this column as a primary key column that also is or is part of a partition key. Sets * {@link #ordering} to null and, if the given boolean is true, then sets the column's - * {@link #keyType} to {@link PrimaryKeyType#PARTITION}, else sets it to null. + * {@link #keyType} to {@link PrimaryKeyType#PARTITIONED}, else sets it to null. * * @return this */ public ColumnSpecification partition(boolean partition) { - this.keyType = partition ? PARTITION : null; + this.keyType = partition ? PARTITIONED : null; this.ordering = null; return this; } @@ -115,7 +116,7 @@ public class ColumnSpecification { /** * Toggles the identification of this column as a primary key column. If the given boolean is true, then - * sets the column's {@link #keyType} to {@link PrimaryKeyType#PARTITION} and {@link #ordering} to the given + * sets the column's {@link #keyType} to {@link PrimaryKeyType#PARTITIONED} and {@link #ordering} to the given * {@link Ordering} , else sets both {@link #keyType} and {@link #ordering} to null. * * @return this diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableDescriptor.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableDescriptor.java index 300826fb0..116e1dedd 100644 --- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableDescriptor.java +++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableDescriptor.java @@ -22,6 +22,7 @@ import java.util.Map; * Describes a table. * * @author Matthew T. Adams + * @author Alex Shvid */ public interface TableDescriptor { @@ -48,12 +49,12 @@ public interface TableDescriptor { /** * Returns an unmodifiable list of all primary key columns that are not also partition key columns. */ - public List getPrimaryKeyColumns(); + public List getClusteredKeyColumns(); /** * Returns an unmodifiable list of all partition and primary key columns. */ - public List getKeyColumns(); + public List getPrimaryKeyColumns(); /** * Returns an unmodifiable list of all non-key columns. diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableSpecification.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableSpecification.java index 512c8af2e..7b89c923b 100644 --- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableSpecification.java +++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/keyspace/TableSpecification.java @@ -15,7 +15,7 @@ */ package org.springframework.cassandra.core.keyspace; -import static org.springframework.cassandra.core.PrimaryKeyType.PARTITION; +import static org.springframework.cassandra.core.PrimaryKeyType.PARTITIONED; import static org.springframework.cassandra.core.PrimaryKeyType.CLUSTERED; import static org.springframework.cassandra.core.Ordering.ASCENDING; @@ -33,6 +33,7 @@ import com.datastax.driver.core.DataType; * standalone {@link TableDescriptor}, independent of {@link CreateTableSpecification}. * * @author Matthew T. Adams + * @author Alex Shvid */ public class TableSpecification extends TableOptionsSpecification> implements TableDescriptor { @@ -49,7 +50,7 @@ public class TableSpecification extends TableOptionsSpecification primaryKeyColumns = new ArrayList(); + private List clusteredKeyColumns = new ArrayList(); /** * List of only those columns that are not partition or primary key columns. @@ -74,7 +75,7 @@ public class TableSpecification extends TableOptionsSpecification extends TableOptionsSpecification extends TableOptionsSpecification extends TableOptionsSpecification extends TableOptionsSpecification getPrimaryKeyColumns() { - return Collections.unmodifiableList(primaryKeyColumns); + public List getClusteredKeyColumns() { + return Collections.unmodifiableList(clusteredKeyColumns); } /** * Returns an unmodifiable list of all primary key columns that are not also partition key columns. */ - public List getKeyColumns() { + public List getPrimaryKeyColumns() { - ArrayList keyColumns = new ArrayList(); - keyColumns.addAll(partitionKeyColumns); - keyColumns.addAll(primaryKeyColumns); + ArrayList primaryKeyColumns = new ArrayList(); + primaryKeyColumns.addAll(partitionKeyColumns); + primaryKeyColumns.addAll(clusteredKeyColumns); - return Collections.unmodifiableList(keyColumns); + return Collections.unmodifiableList(primaryKeyColumns); } /** diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java index 865be7af9..281933a6c 100644 --- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java +++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CqlTableSpecificationAssertions.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011-2013 the original author or authors. + * + * 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. + */ package org.springframework.cassandra.test.integration.core.cql.generator; import static junit.framework.Assert.assertEquals; @@ -35,7 +50,7 @@ public class CqlTableSpecificationAssertions { } public static void assertPrimaryKeyColumns(TableDescriptor expected, TableMetadata actual) { - assertColumns(expected.getKeyColumns(), actual.getPrimaryKey()); + assertColumns(expected.getPrimaryKeyColumns(), actual.getPrimaryKey()); } public static void assertOptions(Map expected, Options actual) {