From d33e391dbbf922928cb06bdcccceafd0b3f594ea Mon Sep 17 00:00:00 2001 From: Alex Shvid Date: Mon, 2 Dec 2013 16:06:34 -0800 Subject: [PATCH] compound keys renaming --- .../AbstractCassandraConfiguration.java | 11 ++--- .../data/cassandra/mapping/CompoundKey.java | 45 +++++++++++++++++++ ...{CompositeRowId.java => PartitionKey.java} | 16 +------ 3 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompoundKey.java rename spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/{CompositeRowId.java => PartitionKey.java} (73%) diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java index 0009d0010..2baf1030a 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/AbstractCassandraConfiguration.java @@ -22,7 +22,6 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.cassandra.core.CassandraOperations; import org.springframework.cassandra.core.CassandraTemplate; -import org.springframework.data.cassandra.core.SpringDataKeyspace; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.context.annotation.Configuration; @@ -32,9 +31,11 @@ import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.CassandraAdminOperations; import org.springframework.data.cassandra.core.CassandraAdminTemplate; +import org.springframework.data.cassandra.core.SpringDataKeyspace; import org.springframework.data.cassandra.mapping.CassandraMappingContext; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; import org.springframework.data.cassandra.mapping.CassandraPersistentProperty; +import org.springframework.data.cassandra.mapping.CompoundKey; import org.springframework.data.cassandra.mapping.Table; import org.springframework.data.mapping.context.MappingContext; import org.springframework.util.ClassUtils; @@ -74,8 +75,8 @@ public abstract class AbstractCassandraConfiguration implements BeanClassLoaderA public abstract Cluster cluster() throws Exception; /** - * Creates a {@link Session} to be used by the {@link SpringDataKeyspace}. Will use the {@link Cluster} instance configured in - * {@link #cluster()}. + * Creates a {@link Session} to be used by the {@link SpringDataKeyspace}. Will use the {@link Cluster} instance + * configured in {@link #cluster()}. * * @see #cluster() * @see #Keyspace() @@ -93,8 +94,8 @@ public abstract class AbstractCassandraConfiguration implements BeanClassLoaderA } /** - * Creates a {@link SpringDataKeyspace} to be used by the {@link CassandraTemplate}. Will use the {@link Session} instance - * configured in {@link #session()} and {@link CassandraConverter} configured in {@link #converter()}. + * Creates a {@link SpringDataKeyspace} to be used by the {@link CassandraTemplate}. Will use the {@link Session} + * instance configured in {@link #session()} and {@link CassandraConverter} configured in {@link #converter()}. * * @see #cluster() * @see #Keyspace() diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompoundKey.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompoundKey.java new file mode 100644 index 000000000..f059d4f65 --- /dev/null +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompoundKey.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010-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.data.cassandra.mapping; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Identifies compound keys class in the Cassandra table that contains several fields. Same as + * + * @org.springframework.data.annotation.Id + * + * Example: + * + * @CompoundKey class AccountPK { String account; String region; } + * + * @Table class Account { + * @PrimaryKey AccountPK pk; } + * + * + * @author Alex Shvid + */ + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface CompoundKey { + +} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompositeRowId.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/PartitionKey.java similarity index 73% rename from spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompositeRowId.java rename to spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/PartitionKey.java index 2ceca4e1d..8a340e855 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CompositeRowId.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/PartitionKey.java @@ -20,25 +20,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.data.annotation.Id; - /** - * Identifies composite row ID in the Cassandra table that contains several fields. Same as - * @org.springframework.data.annotation.Id - * - * Example: - * - * class AccountPK { String account; String region; } - * - * @Table class Account { - * @CompositeRowId Account pk; } - * + * Identifies partition key in the Cassandra compound key class. * * @author Alex Shvid */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE }) -@Id -public @interface CompositeRowId { +public @interface PartitionKey { }