Skip to content

Commit 8e56734

Browse files
Kevin Gallardoolim7t
authored andcommitted
JAVA-477 : Add USING options in mapper for delete and save operations
1 parent dc2e90f commit 8e56734

10 files changed

Lines changed: 1207 additions & 210 deletions

File tree

changelog/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
- [improvement] Use same pool implementation for protocol v2 and v3
2020
(JAVA-738).
2121
- [improvement] Support CONTAINS / CONTAINS KEY in QueryBuilder (JAVA-677)
22+
- [improvement] Add USING options in mapper for delete and save
23+
operations (JAVA-477/JAVA-540)
2224

2325
Merged from 2.0 branch:
2426

driver-core/src/main/java/com/datastax/driver/core/querybuilder/Delete.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ public Options using(Using using) {
136136
return usings.and(using);
137137
}
138138

139+
/**
140+
* Returns the options for this DELETE statement.
141+
* <p/>
142+
* Chain this with {@link Options#and(Using)} to add options.
143+
*
144+
* @return the options of this DELETE statement.
145+
*/
146+
public Options using() {
147+
return usings;
148+
}
149+
139150
/**
140151
* Sets the 'IF EXISTS' option for this DELETE statement.
141152
*

driver-core/src/main/java/com/datastax/driver/core/querybuilder/Insert.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ public Options using(Using using) {
134134
return usings.and(using);
135135
}
136136

137+
/**
138+
* Returns the options for this INSERT statement.
139+
* <p/>
140+
* Chain this with {@link Options#and(Using)} to add options.
141+
*
142+
* @return the options of this INSERT statement.
143+
*/
144+
public Options using() {
145+
return usings;
146+
}
137147
/**
138148
* Sets the 'IF NOT EXISTS' option for this INSERT statement.
139149
* <p>

driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationParser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.google.common.base.Strings;
2828

2929
import com.datastax.driver.core.ConsistencyLevel;
30-
import com.datastax.driver.core.ProtocolVersion;
3130
import com.datastax.driver.mapping.MethodMapper.EnumParamMapper;
3231
import com.datastax.driver.mapping.MethodMapper.NestedUDTParamMapper;
3332
import com.datastax.driver.mapping.MethodMapper.ParamMapper;
@@ -76,7 +75,7 @@ public static <T> EntityMapper<T> parseEntity(Class<T> entityClass, EntityMapper
7675
if(field.isSynthetic() || (field.getModifiers() & Modifier.STATIC) == Modifier.STATIC)
7776
continue;
7877

79-
if (!mappingManager.supportsAliases && field.getAnnotation(Computed.class) != null)
78+
if (mappingManager.isCassandraV1 && field.getAnnotation(Computed.class) != null)
8079
throw new UnsupportedOperationException("Computed fields are not supported with native protocol v1");
8180

8281
AnnotationChecks.validateAnnotations(field, "entity",
@@ -99,7 +98,7 @@ public static <T> EntityMapper<T> parseEntity(Class<T> entityClass, EntityMapper
9998
}
10099
}
101100

102-
AtomicInteger columnCounter = mappingManager.supportsAliases ? new AtomicInteger(0) : null;
101+
AtomicInteger columnCounter = mappingManager.isCassandraV1 ? null : new AtomicInteger(0);
103102

104103
Collections.sort(pks, fieldComparator);
105104
Collections.sort(ccs, fieldComparator);

0 commit comments

Comments
 (0)