DATACASS-172 - Polishing.
Add tests. Add validations to Cql generators. Enhance JavaDoc. Create FieldSpecification for UDT fields.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -15,31 +15,52 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.keyspace.AddColumnSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.AlterColumnSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.AlterUserTypeSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.ColumnChangeSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.DropColumnSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.RenameColumnSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* CQL generator for generating <code>ALTER TYPE</code> statements.
|
||||
*
|
||||
* CQL generator for generating {@code ALTER TYPE} statements.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see AlterUserTypeSpecification
|
||||
* @see AddColumnSpecification
|
||||
* @see RenameColumnSpecification
|
||||
* @see AlterColumnSpecification
|
||||
*/
|
||||
public class AlterUserTypeCqlGenerator extends UserTypeCqlGenerator<AlterUserTypeSpecification> {
|
||||
public class AlterUserTypeCqlGenerator extends UserTypeNameCqlGenerator<AlterUserTypeSpecification> {
|
||||
|
||||
public static String toCql(AlterUserTypeSpecification specification) {
|
||||
return new AlterUserTypeCqlGenerator(specification).toCql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link AlterUserTypeCqlGenerator} for a {@link AlterUserTypeSpecification}.
|
||||
*
|
||||
* @param specification must not be {@literal null}.
|
||||
*/
|
||||
public AlterUserTypeCqlGenerator(AlterUserTypeSpecification specification) {
|
||||
super(specification);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.cql.generator.UserTypeNameCqlGenerator#toCql(java.lang.StringBuilder)
|
||||
*/
|
||||
@Override
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
|
||||
Assert.notNull(getSpecification().getName(), "User type name must not be null");
|
||||
Assert.isTrue(!getSpecification().getChanges().isEmpty(),
|
||||
String.format("User type [%s] does not contain fields", getSpecification().getName()));
|
||||
|
||||
cql = noNull(cql);
|
||||
|
||||
preambleCql(cql);
|
||||
@@ -50,37 +71,46 @@ public class AlterUserTypeCqlGenerator extends UserTypeCqlGenerator<AlterUserTyp
|
||||
return cql;
|
||||
}
|
||||
|
||||
protected StringBuilder preambleCql(StringBuilder cql) {
|
||||
return noNull(cql).append("ALTER TYPE ").append(spec().getName()).append(" ");
|
||||
private StringBuilder preambleCql(StringBuilder cql) {
|
||||
return noNull(cql).append("ALTER TYPE ").append(spec().getName()).append(' ');
|
||||
}
|
||||
|
||||
protected StringBuilder changesCql(StringBuilder cql) {
|
||||
private StringBuilder changesCql(StringBuilder cql) {
|
||||
cql = noNull(cql);
|
||||
|
||||
boolean first = true;
|
||||
boolean lastChangeWasRename = false;
|
||||
|
||||
for (ColumnChangeSpecification change : spec().getChanges()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
cql.append(" ");
|
||||
cql.append(' ');
|
||||
}
|
||||
getCqlGeneratorFor(change).toCql(cql);
|
||||
getCqlGeneratorFor(change, lastChangeWasRename).toCql(cql);
|
||||
|
||||
lastChangeWasRename = change instanceof RenameColumnSpecification;
|
||||
}
|
||||
|
||||
return cql;
|
||||
}
|
||||
|
||||
protected ColumnChangeCqlGenerator<?> getCqlGeneratorFor(ColumnChangeSpecification change) {
|
||||
private ColumnChangeCqlGenerator<?> getCqlGeneratorFor(ColumnChangeSpecification change,
|
||||
boolean lastChangeWasRename) {
|
||||
|
||||
if (change instanceof AddColumnSpecification) {
|
||||
return new AddColumnCqlGenerator((AddColumnSpecification) change);
|
||||
}
|
||||
if (change instanceof DropColumnSpecification) {
|
||||
return new DropColumnCqlGenerator((DropColumnSpecification) change);
|
||||
|
||||
if (change instanceof RenameColumnSpecification) {
|
||||
return new RenameColumnCqlGenerator(lastChangeWasRename ? "AND" : RenameColumnCqlGenerator.RENAME, change);
|
||||
}
|
||||
|
||||
if (change instanceof AlterColumnSpecification) {
|
||||
return new AlterColumnCqlGenerator((AlterColumnSpecification) change);
|
||||
}
|
||||
throw new IllegalArgumentException("unknown ColumnChangeSpecification type: " + change.getClass().getName());
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Unknown ColumnChangeSpecification type: %s", change.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -15,29 +15,46 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.keyspace.ColumnSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.FieldSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* CQL generator for generating a <code>CREATE TYPE</code> statement.
|
||||
*
|
||||
* CQL generator for generating a {@code CREATE TYPE} statement.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CreateUserTypeSpecification
|
||||
*/
|
||||
public class CreateUserTypeCqlGenerator extends UserTypeCqlGenerator<CreateUserTypeSpecification> {
|
||||
public class CreateUserTypeCqlGenerator extends UserTypeNameCqlGenerator<CreateUserTypeSpecification> {
|
||||
|
||||
public static String toCql(CreateUserTypeSpecification specification) {
|
||||
return new CreateUserTypeCqlGenerator(specification).toCql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link CreateUserTypeCqlGenerator} for a given {@link CreateUserTypeSpecification}.
|
||||
*
|
||||
* @param specification must not be {@literal null}.
|
||||
*/
|
||||
public CreateUserTypeCqlGenerator(CreateUserTypeSpecification specification) {
|
||||
super(specification);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.cql.generator.UserTypeNameCqlGenerator#toCql(java.lang.StringBuilder)
|
||||
*/
|
||||
@Override
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
|
||||
Assert.notNull(getSpecification().getName(), "User type name must not be null");
|
||||
Assert.isTrue(!getSpecification().getFields().isEmpty(),
|
||||
String.format("User type [%s] does not contain fields", getSpecification().getName()));
|
||||
|
||||
cql = noNull(cql);
|
||||
|
||||
preambleCql(cql);
|
||||
@@ -48,21 +65,29 @@ public class CreateUserTypeCqlGenerator extends UserTypeCqlGenerator<CreateUserT
|
||||
return cql;
|
||||
}
|
||||
|
||||
protected StringBuilder preambleCql(StringBuilder cql) {
|
||||
private StringBuilder preambleCql(StringBuilder cql) {
|
||||
return noNull(cql).append("CREATE TYPE ").append(spec().getIfNotExists() ? "IF NOT EXISTS " : "")
|
||||
.append(spec().getName());
|
||||
}
|
||||
|
||||
protected StringBuilder columns(StringBuilder cql) {
|
||||
private StringBuilder columns(StringBuilder cql) {
|
||||
|
||||
cql = noNull(cql);
|
||||
|
||||
// begin columns
|
||||
cql.append(" (");
|
||||
for (ColumnSpecification col : spec().getColumns()) {
|
||||
col.toCql(cql).append(", ");
|
||||
|
||||
boolean first = true;
|
||||
for (FieldSpecification col : spec().getFields()) {
|
||||
|
||||
if (!first) {
|
||||
cql.append(", ");
|
||||
}
|
||||
|
||||
col.toCql(cql);
|
||||
|
||||
first = false;
|
||||
}
|
||||
cql.delete(cql.length() - 2, cql.length());
|
||||
|
||||
cql.append(")");
|
||||
// end columns
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -15,14 +15,17 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.keyspace.DropUserTypeSpecification;
|
||||
|
||||
/**
|
||||
* CQL generator for generating a <code>DROP TYPE</code> statement.
|
||||
*
|
||||
* CQL generator for generating a {@code DROP TYPE} statement.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see DropUserTypeSpecification
|
||||
*/
|
||||
public class DropUserTypeCqlGenerator extends UserTypeNameCqlGenerator<DropUserTypeSpecification> {
|
||||
|
||||
@@ -30,14 +33,22 @@ public class DropUserTypeCqlGenerator extends UserTypeNameCqlGenerator<DropUserT
|
||||
return new DropUserTypeCqlGenerator(specification).toCql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link DropUserTypeCqlGenerator} for a given {@link DropUserTypeSpecification}.
|
||||
*
|
||||
* @param specification must not be {@literal null}.
|
||||
*/
|
||||
public DropUserTypeCqlGenerator(DropUserTypeSpecification specification) {
|
||||
super(specification);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.cql.generator.UserTypeNameCqlGenerator#toCql(java.lang.StringBuilder)
|
||||
*/
|
||||
@Override
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return noNull(cql).append("DROP TYPE ")
|
||||
// .append(spec().getIfExists() ? "IF EXISTS " : "")
|
||||
.append(spec().getName()).append(";");
|
||||
return noNull(cql).append("DROP TYPE ").append(spec().getIfExists() ? "IF EXISTS " : "").append(spec().getName())
|
||||
.append(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.cassandra.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.keyspace.ColumnChangeSpecification;
|
||||
import org.springframework.cassandra.core.keyspace.RenameColumnSpecification;
|
||||
|
||||
/**
|
||||
@@ -30,14 +31,24 @@ import org.springframework.cassandra.core.keyspace.RenameColumnSpecification;
|
||||
*/
|
||||
public class RenameColumnCqlGenerator extends ColumnChangeCqlGenerator<RenameColumnSpecification> {
|
||||
|
||||
static final String RENAME = "RENAME";
|
||||
|
||||
final String keyword;
|
||||
|
||||
RenameColumnCqlGenerator(RenameColumnSpecification specification) {
|
||||
this(RENAME, specification);
|
||||
}
|
||||
|
||||
public RenameColumnCqlGenerator(String keyword, ColumnChangeSpecification specification) {
|
||||
super(specification);
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.cql.generator.ColumnChangeCqlGenerator#toCql(java.lang.StringBuilder)
|
||||
*/
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return noNull(cql).append("RENAME ").append(spec().getName()).append(" TO ").append(spec().getTargetName());
|
||||
return noNull(cql).append(keyword).append(' ').append(spec().getName()).append(" TO ")
|
||||
.append(spec().getTargetName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -19,9 +19,13 @@ import org.springframework.cassandra.core.keyspace.UserTypeNameSpecification;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Fabio J. Mendes
|
||||
* Abstract class to support User type CQL generation.
|
||||
*
|
||||
* @param <T>
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @param <T> specification type
|
||||
* @since 1.5
|
||||
* @see UserTypeNameSpecification
|
||||
*/
|
||||
public abstract class UserTypeNameCqlGenerator<T extends UserTypeNameSpecification<T>> {
|
||||
|
||||
@@ -29,12 +33,24 @@ public abstract class UserTypeNameCqlGenerator<T extends UserTypeNameSpecificati
|
||||
|
||||
private UserTypeNameSpecification<T> specification;
|
||||
|
||||
/**
|
||||
* Creates a new {@link UserTypeNameCqlGenerator}.
|
||||
*
|
||||
* @param specification must not be {@literal null}.
|
||||
*/
|
||||
public UserTypeNameCqlGenerator(UserTypeNameSpecification<T> specification) {
|
||||
setSpecification(specification);
|
||||
}
|
||||
|
||||
protected void setSpecification(UserTypeNameSpecification<T> specification) {
|
||||
Assert.notNull(specification);
|
||||
/**
|
||||
* Sets the {@link UserTypeNameSpecification}.
|
||||
*
|
||||
* @param specification must not be {@literal null}.
|
||||
*/
|
||||
protected final void setSpecification(UserTypeNameSpecification<T> specification) {
|
||||
|
||||
Assert.notNull(specification, "UserTypeNameSpecification must not be null");
|
||||
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Value object for altering a column.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
* @author Mark Paluch
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class AlterColumnSpecification extends ColumnTypeChangeSpecification {
|
||||
|
||||
public AlterColumnSpecification(String name, DataType type) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -24,11 +24,16 @@ import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Builder class to construct an <code>ALTER TYPE</code> specification.
|
||||
*
|
||||
* Builder class to construct an {@code ALTER TYPE} specification.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class AlterUserTypeSpecification extends UserTypeSpecification<AlterUserTypeSpecification> {
|
||||
public class AlterUserTypeSpecification extends UserTypeNameSpecification<AlterUserTypeSpecification> {
|
||||
|
||||
private final List<ColumnChangeSpecification> changes = new ArrayList<ColumnChangeSpecification>();
|
||||
|
||||
/**
|
||||
* Entry point into the {@link AlterUserTypeSpecification}'s fluent API to alter a type. Convenient if imported
|
||||
@@ -42,56 +47,92 @@ public class AlterUserTypeSpecification extends UserTypeSpecification<AlterUserT
|
||||
* Entry point into the {@link AlterUserTypeSpecification}'s fluent API to alter a type. Convenient if imported
|
||||
* statically.
|
||||
*/
|
||||
public static AlterUserTypeSpecification alterType(CqlIdentifier tableName) {
|
||||
return (AlterUserTypeSpecification) new AlterUserTypeSpecification().name(tableName);
|
||||
public static AlterUserTypeSpecification alterType(CqlIdentifier typeName) {
|
||||
return alterType().name(typeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point into the {@link AlterUserTypeSpecification}'s fluent API to alter a type. Convenient if imported
|
||||
* statically.
|
||||
*/
|
||||
public static AlterUserTypeSpecification alterType(String tableName) {
|
||||
return (AlterUserTypeSpecification) new AlterUserTypeSpecification().name(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlterUserTypeSpecification name(String name) {
|
||||
return (AlterUserTypeSpecification) super.name(name);
|
||||
public static AlterUserTypeSpecification alterType(String typeName) {
|
||||
return alterType(CqlIdentifier.cqlId(typeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of column changes.
|
||||
*/
|
||||
private List<ColumnChangeSpecification> changes = new ArrayList<ColumnChangeSpecification>();
|
||||
|
||||
/*
|
||||
* Adds a <code>DROP</code> to the list of column changes.
|
||||
* Adds an {@literal ADD} to the list of field changes.
|
||||
*
|
||||
* DW Removed as this only works in C* 2.0
|
||||
* @param field must not be empty or {@literal null}.
|
||||
* @param type must not be {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
// public AlterUserTypeSpecification drop(String column) {
|
||||
// changes.add(new DropColumnSpecification(column));
|
||||
// return this;
|
||||
// }
|
||||
public AlterUserTypeSpecification add(String field, DataType type) {
|
||||
return add(CqlIdentifier.cqlId(field), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an <code>ADD</code> to the list of column changes.
|
||||
* Adds an {@literal ADD} to the list of field changes.
|
||||
*
|
||||
* @param field must not be {@literal null}.
|
||||
* @param type must not be {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
public AlterUserTypeSpecification add(String column, DataType type) {
|
||||
changes.add(new AddColumnSpecification(column, type));
|
||||
public AlterUserTypeSpecification add(CqlIdentifier field, DataType type) {
|
||||
|
||||
changes.add(new AddColumnSpecification(field, type));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an <code>ALTER</code> to the list of column changes.
|
||||
* Adds an {@literal ALTER} to the list of field changes.
|
||||
*
|
||||
* @param field must not be empty or {@literal null}.
|
||||
* @param type must not be {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
public AlterUserTypeSpecification alter(String column, DataType type) {
|
||||
changes.add(new AlterColumnSpecification(column, type));
|
||||
public AlterUserTypeSpecification alter(String field, DataType type) {
|
||||
return alter(CqlIdentifier.cqlId(field), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an {@literal ALTER} to the list of field changes.
|
||||
*
|
||||
* @param field must not be {@literal null}.
|
||||
* @param type must not be {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
public AlterUserTypeSpecification alter(CqlIdentifier field, DataType type) {
|
||||
|
||||
changes.add(new AlterColumnSpecification(field, type));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of column changes.
|
||||
* Adds an {@literal RENAME} to the list of field changes.
|
||||
*
|
||||
* @param from must not be empty or {@literal null}.
|
||||
* @param to must not be empty or {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
public AlterUserTypeSpecification rename(String from, String to) {
|
||||
return rename(CqlIdentifier.cqlId(from), CqlIdentifier.cqlId(to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an {@literal RENAME} to the list of field changes.
|
||||
*
|
||||
* @param from must not be {@literal null}.
|
||||
* @param to must not be empty or {@literal null}.
|
||||
* @return {@code this} {@link AlterUserTypeSpecification}.
|
||||
*/
|
||||
public AlterUserTypeSpecification rename(CqlIdentifier from, CqlIdentifier to) {
|
||||
|
||||
changes.add(new RenameColumnSpecification(from, to));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable list of field changes.
|
||||
*/
|
||||
public List<ColumnChangeSpecification> getChanges() {
|
||||
return Collections.unmodifiableList(changes);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -18,12 +18,17 @@ package org.springframework.cassandra.core.keyspace;
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
/**
|
||||
* Builder class to construct a <code>CREATE TYPE</code> specification.
|
||||
*
|
||||
* Builder class to construct a {@code CREATE TYPE} specification.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class CreateUserTypeSpecification extends UserTypeSpecification<CreateUserTypeSpecification> {
|
||||
|
||||
private boolean ifNotExists;
|
||||
|
||||
/**
|
||||
* Entry point into the {@link CreateUserTypeSpecification}'s fluent API to create a type. Convenient if imported
|
||||
* statically.
|
||||
@@ -37,7 +42,7 @@ public class CreateUserTypeSpecification extends UserTypeSpecification<CreateUse
|
||||
* statically.
|
||||
*/
|
||||
public static CreateUserTypeSpecification createType(CqlIdentifier name) {
|
||||
return new CreateUserTypeSpecification().name(name);
|
||||
return createType().name(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,41 +50,35 @@ public class CreateUserTypeSpecification extends UserTypeSpecification<CreateUse
|
||||
* statically.
|
||||
*/
|
||||
public static CreateUserTypeSpecification createType(String name) {
|
||||
return new CreateUserTypeSpecification().name(name);
|
||||
}
|
||||
|
||||
private boolean ifNotExists = false;
|
||||
|
||||
@Override
|
||||
public CreateUserTypeSpecification name(CqlIdentifier name) {
|
||||
return (CreateUserTypeSpecification) super.name(name);
|
||||
return createType(CqlIdentifier.cqlId(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the inclusion of an <code>IF NOT EXISTS</code> clause.
|
||||
* Enables the inclusion of an{@code IF NOT EXISTS} clause.
|
||||
*
|
||||
* @return this
|
||||
* @return this {@link CreateUserTypeSpecification}.
|
||||
*/
|
||||
public CreateUserTypeSpecification ifNotExists() {
|
||||
return ifNotExists(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the inclusion of an <code>IF NOT EXISTS</code> clause.
|
||||
*
|
||||
* @return this
|
||||
* Sets the inclusion of an {@code IF NOT EXISTS} clause.
|
||||
*
|
||||
* @param ifNotExists {@literal true} to include an {@code IF NOT EXISTS} clause, {@literal false} to omit the
|
||||
* {@code IF NOT EXISTS} clause.
|
||||
* @return this {@link CreateUserTypeSpecification}.
|
||||
*/
|
||||
public CreateUserTypeSpecification ifNotExists(boolean ifNotExists) {
|
||||
|
||||
this.ifNotExists = ifNotExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@literal true} if the {@code IF NOT EXISTS} clause is included.
|
||||
*/
|
||||
public boolean getIfNotExists() {
|
||||
return ifNotExists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateUserTypeSpecification name(String name) {
|
||||
return (CreateUserTypeSpecification) super.name(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -18,28 +18,16 @@ package org.springframework.cassandra.core.keyspace;
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
/**
|
||||
* Builder class that supports the construction of <code>DROP TYPE</code> specifications.
|
||||
*
|
||||
* Builder class that supports the construction of {@code DROP TYPE} specifications.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class DropUserTypeSpecification extends UserTypeNameSpecification<DropUserTypeSpecification> {
|
||||
|
||||
// private boolean ifExists;
|
||||
|
||||
// Added in Cassandra 2.0.
|
||||
|
||||
// public DropTableSpecification ifExists() {
|
||||
// return ifExists(true);
|
||||
// }
|
||||
//
|
||||
// public DropTableSpecification ifExists(boolean ifExists) {
|
||||
// this.ifExists = ifExists;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public boolean getIfExists() {
|
||||
// return ifExists;
|
||||
// }
|
||||
private boolean ifExists;
|
||||
|
||||
/**
|
||||
* Entry point into the {@link DropUserTypeSpecification}'s fluent API to drop a type. Convenient if imported
|
||||
@@ -51,23 +39,50 @@ public class DropUserTypeSpecification extends UserTypeNameSpecification<DropUse
|
||||
|
||||
/**
|
||||
* Entry point into the {@link DropUserTypeSpecification}'s fluent API to drop a type. Convenient if imported
|
||||
* statically. This static method is shorter than the no-arg form, which would be
|
||||
* <code>dropType().name(typeName)</code>.
|
||||
* statically.
|
||||
*
|
||||
* @param typeName The name of the type to drop.
|
||||
*/
|
||||
public static DropUserTypeSpecification dropType(CqlIdentifier typeName) {
|
||||
return new DropUserTypeSpecification().name(typeName);
|
||||
return dropType().name(typeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point into the {@link DropUserTypeSpecification}'s fluent API to drop a type. Convenient if imported
|
||||
* statically. This static method is shorter than the no-arg form, which would be
|
||||
* <code>dropType().name(typeName)</code>.
|
||||
* statically.
|
||||
*
|
||||
* @param typeName The name of the type to drop.
|
||||
*/
|
||||
public static DropUserTypeSpecification dropType(String typeName) {
|
||||
return new DropUserTypeSpecification().name(typeName);
|
||||
return dropType(CqlIdentifier.cqlId(typeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the inclusion of an{@code IF EXISTS} clause.
|
||||
*
|
||||
* @return this {@link DropUserTypeSpecification}.
|
||||
*/
|
||||
public DropUserTypeSpecification ifExists() {
|
||||
return ifExists(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the inclusion of an {@code IF EXISTS} clause.
|
||||
*
|
||||
* @param ifNotExists {@literal true} to include an {@code IF EXISTS} clause, {@literal false} to omit the
|
||||
* {@code IF NOT EXISTS} clause.
|
||||
* @return this {@link DropUserTypeSpecification}.
|
||||
*/
|
||||
public DropUserTypeSpecification ifExists(boolean ifExists) {
|
||||
|
||||
this.ifExists = ifExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@literal true} if the {@code IF EXISTS} clause is included.
|
||||
*/
|
||||
public boolean getIfExists() {
|
||||
return ifExists;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
import static org.springframework.cassandra.core.cql.CqlStringUtils.*;
|
||||
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Builder class to specify fields.
|
||||
* <p/>
|
||||
* A {@link FieldSpecification} consists of a name and a {@link DataType}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class FieldSpecification {
|
||||
|
||||
private CqlIdentifier name;
|
||||
private DataType type;
|
||||
|
||||
/**
|
||||
* Sets the field name.
|
||||
*
|
||||
* @param name must not be empty or {@literal null}.
|
||||
* @return {@code this} {@link FieldSpecification}.
|
||||
*/
|
||||
public FieldSpecification name(String name) {
|
||||
return name(cqlId(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field name.
|
||||
*
|
||||
* @param name must not be {@literal null}.
|
||||
* @return {@code this} {@link FieldSpecification}.
|
||||
*/
|
||||
public FieldSpecification name(CqlIdentifier name) {
|
||||
|
||||
Assert.notNull(name, "CqlIdentifier must not be null");
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column's type.
|
||||
*
|
||||
* @param type The data type of the field, must not be {@literal null}.
|
||||
* @return {@code this} {@link FieldSpecification}.
|
||||
*/
|
||||
public FieldSpecification type(DataType type) {
|
||||
|
||||
Assert.notNull(type, "DataType must not be null");
|
||||
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toCql() {
|
||||
return toCql(null).toString();
|
||||
}
|
||||
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return noNull(cql).append(name).append(" ").append(type);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return toCql(null).toString();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -15,40 +15,50 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
|
||||
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract builder class to support the construction of user type specifications.
|
||||
*
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @param <T> The subtype of the {@link UserTypeNameSpecification}
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public abstract class UserTypeNameSpecification<T extends UserTypeNameSpecification<T>> {
|
||||
|
||||
/**
|
||||
* The name of the type.
|
||||
*/
|
||||
private CqlIdentifier name;
|
||||
|
||||
/**
|
||||
* Sets the type name.
|
||||
*
|
||||
* @param name must not be empty or {@literal null}.
|
||||
* @return this
|
||||
*/
|
||||
public T name(String name) {
|
||||
return name(cqlId(name));
|
||||
return name(CqlIdentifier.cqlId(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type name.
|
||||
*
|
||||
* @param name must not be {@literal null}.
|
||||
* @return this
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T name(CqlIdentifier name) {
|
||||
Assert.notNull(name);
|
||||
|
||||
Assert.notNull(name, "Name must not be null");
|
||||
|
||||
this.name = name;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user type name.
|
||||
*/
|
||||
public CqlIdentifier getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId;
|
||||
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -25,53 +25,48 @@ import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
|
||||
/**
|
||||
* Builder class to support the construction of user type specifications that have columns. This class can also be used as a
|
||||
* standalone {@link UserTypeDescriptor}, independent of {@link CreateUserTypeSpecification}.
|
||||
*
|
||||
* Builder class to support the construction of user type specifications that have columns. This class can also be used
|
||||
* as a standalone {@link UserTypeSpecification}.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
* @see CqlIdentifier
|
||||
*/
|
||||
public class UserTypeSpecification<T> extends UserTypeNameSpecification<UserTypeSpecification<T>> implements UserTypeDescriptor {
|
||||
public class UserTypeSpecification<T extends UserTypeSpecification<T>> extends UserTypeNameSpecification<T> {
|
||||
|
||||
private final List<FieldSpecification> fields = new ArrayList<FieldSpecification>();
|
||||
|
||||
/**
|
||||
* List of all columns.
|
||||
*/
|
||||
private List<ColumnSpecification> columns = new ArrayList<ColumnSpecification>();
|
||||
|
||||
/**
|
||||
* Adds the given column to the type.
|
||||
* Adds the given field to the type.
|
||||
*
|
||||
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
|
||||
* @param type The data type of the column.
|
||||
* @param name must not be empty or {@literal null}.
|
||||
* @param type The data type of the field.
|
||||
* @return {@code this} specification.
|
||||
*/
|
||||
public T column(String name, DataType type) {
|
||||
return column(cqlId(name), type, false);
|
||||
public T field(String name, DataType type) {
|
||||
return field(cqlId(name), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given column to the type.
|
||||
*
|
||||
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
|
||||
* @param type The data type of the column.
|
||||
* Adds an {@literal ADD} to the list of field changes.
|
||||
*
|
||||
* @param name must not {@literal null}.
|
||||
* @param type must not be {@literal null}.
|
||||
* @return {@code this} specification.
|
||||
*/
|
||||
public T column(CqlIdentifier name, DataType type) {
|
||||
return column(name, type, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected T column(CqlIdentifier name, DataType type, boolean frozen) {
|
||||
ColumnSpecification column = new ColumnSpecification().name(name).type(type);
|
||||
columns.add(column);
|
||||
public T field(CqlIdentifier name, DataType type) {
|
||||
|
||||
fields.add(new FieldSpecification().name(name).type(type));
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of all columns.
|
||||
* @return an unmodifiable list of all fields.
|
||||
*/
|
||||
@Override
|
||||
public List<ColumnSpecification> getColumns() {
|
||||
return Collections.unmodifiableList(columns);
|
||||
public List<FieldSpecification> getFields() {
|
||||
return Collections.unmodifiableList(fields);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.cql.generator;
|
||||
|
||||
import static org.springframework.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.keyspace.AlterUserTypeSpecification;
|
||||
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link AlterUserTypeCqlGenerator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
session.execute("DROP TYPE IF EXISTS address;");
|
||||
session.execute("CREATE TYPE address (zip text, state text);");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldAddField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
|
||||
.add("street", DataType.varchar());
|
||||
|
||||
session.execute(toCql(spec));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldAlterField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
|
||||
.alter("zip", DataType.varchar());
|
||||
|
||||
session.execute(toCql(spec));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldRenameField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
|
||||
.rename("zip", "zap");
|
||||
|
||||
session.execute(toCql(spec));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldRenameFields() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
|
||||
.rename("zip", "zap") //
|
||||
.rename("state", "county");
|
||||
|
||||
session.execute(toCql(spec));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsIfNameIsNotSet() {
|
||||
toCql(AlterUserTypeSpecification.alterType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(AlterUserTypeSpecification.alterType().name("hello"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.cql.generator;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.keyspace.AlterUserTypeSpecification;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AlterUserTypeCqlGenerator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class AlterUserTypeCqlGeneratorUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldAddField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
|
||||
.add("zip", DataType.varchar());
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("ALTER TYPE address ADD zip varchar;")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldAlterField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
|
||||
.alter("zip", DataType.varchar());
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("ALTER TYPE address ALTER zip TYPE varchar;")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldRenameField() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
|
||||
.rename("zip", "zap");
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("ALTER TYPE address RENAME zip TO zap;")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void alterTypeShouldRenameFields() {
|
||||
|
||||
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
|
||||
.rename("zip", "zap") //
|
||||
.rename("city", "county");
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("ALTER TYPE address RENAME zip TO zap AND city TO county;")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsIfNameIsNotSet() {
|
||||
toCql(AlterUserTypeSpecification.alterType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(AlterUserTypeSpecification.alterType().name("hello"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.cql.generator;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cassandra.core.cql.generator.CreateUserTypeCqlGenerator.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification;
|
||||
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
import com.datastax.driver.core.KeyspaceMetadata;
|
||||
import com.datastax.driver.core.UserType;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link CreateUserTypeCqlGenerator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
session.execute("DROP TYPE IF EXISTS person;");
|
||||
session.execute("DROP TYPE IF EXISTS address;");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createUserType() {
|
||||
|
||||
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
|
||||
.createType("address") //
|
||||
.field("zip", DataType.ascii()) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
session.execute(toCql(spec));
|
||||
|
||||
KeyspaceMetadata keyspace = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());
|
||||
UserType address = keyspace.getUserType("address");
|
||||
assertThat(address.getFieldNames(), contains("zip", "city"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createUserTypeIfNotExists() {
|
||||
|
||||
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
|
||||
.createType() //
|
||||
.name("address").ifNotExists().field("zip", DataType.ascii()) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
session.execute(toCql(spec));
|
||||
|
||||
KeyspaceMetadata keyspace = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());
|
||||
UserType address = keyspace.getUserType("address");
|
||||
assertThat(address.getFieldNames(), contains("zip", "city"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createNestedUserType() {
|
||||
|
||||
CreateUserTypeSpecification addressSpec = CreateUserTypeSpecification //
|
||||
.createType() //
|
||||
.name("address").ifNotExists().field("zip", DataType.ascii()) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
session.execute(toCql(addressSpec));
|
||||
|
||||
KeyspaceMetadata keyspace = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());
|
||||
UserType address = keyspace.getUserType("address");
|
||||
|
||||
CreateUserTypeSpecification personSpec = CreateUserTypeSpecification //
|
||||
.createType() //
|
||||
.name("person").ifNotExists().field("address", address) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
session.execute(toCql(personSpec));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.cql.generator;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cassandra.core.cql.generator.CreateUserTypeCqlGenerator.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification;
|
||||
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link CreateUserTypeCqlGenerator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class CreateUserTypeCqlGeneratorUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createUserType() {
|
||||
|
||||
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
|
||||
.createType("address") //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("CREATE TYPE address (city varchar);")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createMultiFieldUserType() {
|
||||
|
||||
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
|
||||
.createType("address") //
|
||||
.field("zip", DataType.ascii()) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("CREATE TYPE address (zip ascii, city varchar);")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test
|
||||
public void createUserTypeIfNotExists() {
|
||||
|
||||
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
|
||||
.createType() //
|
||||
.name("address").ifNotExists().field("zip", DataType.ascii()) //
|
||||
.field("city", DataType.varchar());
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("CREATE TYPE IF NOT EXISTS address (zip ascii, city varchar);")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsIfNameIsNotSet() {
|
||||
toCql(CreateUserTypeSpecification.createType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACASS-172
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(CreateUserTypeSpecification.createType().name("hello"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2016 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.core.cql.generator;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cassandra.core.cql.generator.DropUserTypeCqlGenerator.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cassandra.core.keyspace.DropUserTypeSpecification;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DropUserTypeCqlGenerator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class DropUserTypeCqlGeneratorUnitTests {
|
||||
|
||||
@Test
|
||||
public void shouldDropUserType() throws Exception {
|
||||
|
||||
DropUserTypeSpecification spec = DropUserTypeSpecification.dropType("address");
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("DROP TYPE address;")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDropUserTypeIfExists() throws Exception {
|
||||
|
||||
DropUserTypeSpecification spec = DropUserTypeSpecification.dropType("address").ifExists();
|
||||
|
||||
assertThat(toCql(spec), is(equalTo("DROP TYPE IF EXISTS address;")));
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors
|
||||
*
|
||||
* Copyright 2016 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -27,6 +27,8 @@ import com.datastax.driver.core.UserType;
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Matthew T. Adams
|
||||
* @author Mark Paluch
|
||||
* @author Fabio J. Mendes
|
||||
*/
|
||||
public interface CassandraAdminOperations extends CassandraOperations {
|
||||
|
||||
@@ -42,7 +44,8 @@ public interface CassandraAdminOperations extends CassandraOperations {
|
||||
* @param entityClass The class whose fields determine the columns created.
|
||||
* @param optionsByName Table options, given by the string option name and the appropriate option value.
|
||||
*/
|
||||
void createTable(boolean ifNotExists, CqlIdentifier tableName, Class<?> entityClass, Map<String, Object> optionsByName);
|
||||
void createTable(boolean ifNotExists, CqlIdentifier tableName, Class<?> entityClass,
|
||||
Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* Add columns to the given table from the given class. If parameter dropRemovedAttributColumns is true, then this
|
||||
@@ -73,16 +76,21 @@ public interface CassandraAdminOperations extends CassandraOperations {
|
||||
void dropTable(CqlIdentifier tableName);
|
||||
|
||||
/**
|
||||
* @param keyspace
|
||||
* @param tableName
|
||||
* @return
|
||||
* Lookup {@link TableMetadata}.
|
||||
*
|
||||
* @param keyspace must not be empty or {@literal null}.
|
||||
* @param tableName must not be {@literal null}.
|
||||
* @return the {@link TableMetadata} or {@literal null}.
|
||||
*/
|
||||
TableMetadata getTableMetadata(String keyspace, CqlIdentifier tableName);
|
||||
|
||||
/**
|
||||
* @param keyspace
|
||||
* @param userTypeName
|
||||
* @return
|
||||
* Lookup {@link UserType} metadata.
|
||||
*
|
||||
* @param keyspace must not be empty or {@literal null}.
|
||||
* @param userTypeName must not be {@literal null}.
|
||||
* @return the {@link UserType} or {@literal null}.
|
||||
* @since 1.5
|
||||
*/
|
||||
UserType getUserTypeMetadata(String keyspace, CqlIdentifier userTypeName);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
* Copyright 2016 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
|
||||
* 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,
|
||||
@@ -38,6 +38,7 @@ import com.datastax.driver.core.UserType;
|
||||
* Default implementation of {@link CassandraAdminOperations}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Fabio J. Mendes
|
||||
*/
|
||||
public class CassandraAdminTemplate extends CassandraTemplate implements CassandraAdminOperations {
|
||||
|
||||
@@ -53,6 +54,10 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
super(session, converter);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#createTable(boolean, org.springframework.cassandra.core.cql.CqlIdentifier, java.lang.Class, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void createTable(final boolean ifNotExists, final CqlIdentifier tableName, Class<?> entityClass,
|
||||
Map<String, Object> optionsByName) {
|
||||
@@ -63,8 +68,8 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
@Override
|
||||
public Object doInSession(Session s) throws DataAccessException {
|
||||
|
||||
String cql = new CreateTableCqlGenerator(getCassandraMappingContext().
|
||||
getCreateTableSpecificationFor(entity).ifNotExists(ifNotExists)).toCql();
|
||||
String cql = new CreateTableCqlGenerator(
|
||||
getCassandraMappingContext().getCreateTableSpecificationFor(entity).ifNotExists(ifNotExists)).toCql();
|
||||
|
||||
log.debug(cql);
|
||||
|
||||
@@ -74,11 +79,19 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#alterTable(org.springframework.cassandra.core.cql.CqlIdentifier, java.lang.Class, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void alterTable(CqlIdentifier tableName, Class<?> entityClass, boolean dropRemovedAttributeColumns) {
|
||||
throw new UnsupportedOperationException("not yet implemented");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#replaceTable(org.springframework.cassandra.core.cql.CqlIdentifier, java.lang.Class, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void replaceTable(CqlIdentifier tableName, Class<?> entityClass, Map<String, Object> optionsByName) {
|
||||
|
||||
@@ -120,6 +133,10 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
dropTable(getTableName(entityClass));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#dropTable(org.springframework.cassandra.core.cql.CqlIdentifier)
|
||||
*/
|
||||
@Override
|
||||
public void dropTable(CqlIdentifier tableName) {
|
||||
|
||||
@@ -128,10 +145,15 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
execute(DropTableSpecification.dropTable(tableName));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#getTableMetadata(java.lang.String, org.springframework.cassandra.core.cql.CqlIdentifier)
|
||||
*/
|
||||
@Override
|
||||
public TableMetadata getTableMetadata(final String keyspace, final CqlIdentifier tableName) {
|
||||
|
||||
Assert.notNull(tableName);
|
||||
Assert.hasText(keyspace, "Keyspace name must not be empty");
|
||||
Assert.notNull(tableName, "Table name must not be null");
|
||||
|
||||
return execute(new SessionCallback<TableMetadata>() {
|
||||
@Override
|
||||
@@ -141,10 +163,15 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraAdminOperations#getUserTypeMetadata(java.lang.String, org.springframework.cassandra.core.cql.CqlIdentifier)
|
||||
*/
|
||||
@Override
|
||||
public UserType getUserTypeMetadata(final String keyspace, final CqlIdentifier userTypeName) {
|
||||
|
||||
Assert.notNull(userTypeName);
|
||||
Assert.hasText(keyspace, "Keyspace name must not be empty");
|
||||
Assert.notNull(userTypeName, "User type name must not be null");
|
||||
|
||||
return execute(new SessionCallback<UserType>() {
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,12 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Identifies a domain object as Cassandra User Defined type (UDT). User defined types may contain nested user defined
|
||||
* types.
|
||||
*
|
||||
* @author Fabio J. Mendes
|
||||
* @author Mark Paluch
|
||||
* @since 1.5
|
||||
*/
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -30,7 +35,7 @@ import java.lang.annotation.Target;
|
||||
public @interface UserDefinedType {
|
||||
|
||||
/**
|
||||
* The name of the UDT; must be a valid CQL identifier or quoted identifier.
|
||||
* The name of the UDT. Must be a valid CQL identifier or quoted identifier.
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user