java - Can Cassandra LWTs have an IF part in terms of a PRIMARY KEY -
do cassandra lightweight transactions use implied set, , can not have if part in terms of primary key?
i ask because datastax cassandra java driver (version 2.1.5) throws invalidqueryexception
while i'm preparing statement. exception message clear enough:
primary key part name found in set part
except query preparing not attempt set primary key. query is
update operator set password = :password name = :name if name = :name;
as can see, query set password
, not set name
; name
primary key operator
table. exception message make sense if if name = :name
of lightweight transaction implemented using set name = ...
.
if remove if name = :name
part query, driver not complain trying set primry key.
here full stacktrace:
org.springframework.dao.invaliddataaccessresourceusageexception: primary key part name found in set part; nested exception com.datastax.driver.core.exceptions.invalidqueryexception: primary key part name found in set part @ com.example.application.datalayer.driverexceptiontranslator.translateexceptionifpossible(driverexceptiontranslator.java:200) ~[application-user.jar:1.0.0-snapshot] @ com.example.application.datalayer.driverexceptiontranslator$exceptiontranslationadvice.afterthrowing(driverexceptiontranslator.java:50) ~[application-user.jar:1.0.0-snapshot] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.7.0_75] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) ~[na:1.7.0_75] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.7.0_75] @ java.lang.reflect.method.invoke(method.java:606) ~[na:1.7.0_75] @ org.springframework.aop.framework.adapter.throwsadviceinterceptor.invokehandlermethod(throwsadviceinterceptor.java:145) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.adapter.throwsadviceinterceptor.invoke(throwsadviceinterceptor.java:130) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) ~[application-user.jar:1.0.0-snapshot] @ com.example.application.user.$proxy0.adduser(unknown source) ~[na:1.0.0-snapshot] @ com.example.application.user.add.trytoadduser(add.java:294) [application-user.jar:1.0.0-snapshot] @ com.example.application.user.add.performoperation(add.java:266) [application-user.jar:1.0.0-snapshot] @ com.example.application.user.mode.run(mode.java:812) [application-user.jar:1.0.0-snapshot] @ com.example.application.user.mode.runprogram(mode.java:79) [application-user.jar:1.0.0-snapshot] @ com.example.application.user.add.main(add.java:63) [application-user.jar:1.0.0-snapshot] caused by: com.datastax.driver.core.exceptions.invalidqueryexception: primary key part name found in set part @ com.datastax.driver.core.exceptions.invalidqueryexception.copy(invalidqueryexception.java:35) ~[application-user.jar:1.0.0-snapshot] @ com.datastax.driver.core.defaultresultsetfuture.extractcausefromexecutionexception(defaultresultsetfuture.java:289) ~[application-user.jar:1.0.0-snapshot] @ com.datastax.driver.core.abstractsession.prepare(abstractsession.java:79) ~[application-user.jar:1.0.0-snapshot] @ com.example.application.user.cassandrauserrepository$sessionadapter.(cassandrauserrepository.java:80) ~[application-user.jar:1.0.0-snapshot] @ com.example.application.user.cassandrauserrepository.getsessionadapter(cassandrauserrepository.java:447) ~[application-user.jar:1.0.0-snapshot] @ com.example.application.user.cassandrauserrepository.adduser(cassandrauserrepository.java:317) ~[application-user.jar:1.0.0-snapshot] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.7.0_75] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) ~[na:1.7.0_75] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.7.0_75] @ java.lang.reflect.method.invoke(method.java:606) ~[na:1.7.0_75] @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) ~[application-user.jar:1.0.0-snapshot] @ org.springframework.aop.framework.adapter.throwsadviceinterceptor.invoke(throwsadviceinterceptor.java:125) ~[application-user.jar:1.0.0-snapshot] ... 8 common frames omitted caused by: com.datastax.driver.core.exceptions.invalidqueryexception: primary key part name found in set part @ com.datastax.driver.core.responses$error.asexception(responses.java:103) ~[application-user.jar:1.0.0-snapshot] @ com.datastax.driver.core.sessionmanager$1.apply(sessionmanager.java:185) ~[application-user.jar:1.0.0-snapshot] @ com.datastax.driver.core.sessionmanager$1.apply(sessionmanager.java:160) ~[application-user.jar:1.0.0-snapshot] @ com.google.common.util.concurrent.futures$1.apply(futures.java:720) ~[application-user.jar:1.0.0-snapshot] @ com.google.common.util.concurrent.futures$chaininglistenablefuture.run(futures.java:859) ~[application-user.jar:1.0.0-snapshot] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) ~[na:1.7.0_75] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) ~[na:1.7.0_75] @ java.lang.thread.run(thread.java:745) ~[na:1.7.0_75]
you can't set condition on partition key column (if name = 'foo'
), because column restricted in clause (where name = 'foo'
).
there indeed problem error message. has apparently been fixed, cassandra 2.1.4 get: primary key column 'name' cannot have if conditions
.
Comments
Post a Comment