CassandraTemplate @PrimaryKeyColumn annotation, name property, not working on delete

337 views
Skip to first unread message

Barak Cohen

unread,
Jul 22, 2014, 9:12:21 AM7/22/14
to spring-dat...@googlegroups.com

I am using spring-data-cassandra module.

I have an annotated bean using the @Table annotation and a primary class using the @PrimaryKeyClass

the primary key class has 5 primary key columns (2 partitioned and 3 clustered). 2 of my columns has the name property i.e.:

@PrimaryKeyColumn(name="correlated_type", ordinal = 2, type= PrimaryKeyType.CLUSTERED)
private String correlatedType;

When using the CassandraTemplate insert operation everything is working fine but when i am using the cassandraTemplate.deleteAsynchronously(List<entities> list) the columns name are not parsed using the name property but maintain the field name (correlatedType instead of correlated_type).

i tried using a regular delete operation for a single object and tried to use the forceQuote = true property both didn't help.

insert log sample:
[o.s.cassandra.core.CqlTemplate]     asynchronously executing [INSERT INTO identity_correlations(type,value,"**correlated_type**",ts,"**correlated_value**",extra) VALUES ('Participant','p5','Visitor',4,'R3',{'v':'1','labels':'b,c'}) USING TTL 34128000;

delete log sample:
[o.s.cassandra.core.CqlTemplate]     asynchronously executing [BEGIN BATCH DELETE  FROM identity_correlations WHERE **correlatedValue**='p5' AND **correlatedType**='Participant' AND type='Visit' AND value='v1' AND ts=1;DELETE  FROM identity_correlations WHERE correlatedValue='R3' AND correlatedType='Visitor' AND type='Participant' AND value='p5' AND ts=4;DELETE  FROM identity_correlations WHERE correlatedValue='R3' AND correlatedType='Visitor' AND type='Participant' AND value='p5' AND ts=3;APPLY BATCH;]

did anyone encounter this problem before?


This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein. 
If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.

Matthew Adams

unread,
Jul 22, 2014, 10:03:56 AM7/22/14
to Barak Cohen, spring-dat...@googlegroups.com
Please enter an issue for this.  It'd be even better if you can fork the repo, create a failing test case that reproduces this problem, then send a pull request.

I'll have a look as soon as I have time.

-matthew


--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cass...@googlegroups.com.
To post to this group, send email to spring-dat...@googlegroups.com.
Visit this group at http://groups.google.com/group/spring-data-cassandra.
To view this discussion on the web visit https://groups.google.com/d/msgid/spring-data-cassandra/51cb7159-dbc5-4fd6-8f30-2254c3736ca3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
mailto:mat...@matthewadams.me 

Barak Cohen

unread,
Jul 27, 2014, 5:20:43 AM7/27/14
to spring-dat...@googlegroups.com, bar...@liveperson.com
I have created an issue in you Jira - https://jira.spring.io/browse/DATACASS-142
i tried to create a failing test but failed to run your tests (when i ran mvn test all passed but didn't see any log for anyone of the tests and when i ran your existing tests from idea they failed on Spring configuration issues (invested a few hours on it).
i attached my entity object to the issue and the test is pretty simple (insert and select works but the delete doesn't change the CQL do use the name property that contains the _ but uses the field name).

Please let me know if there is something else that i can do to speed things over

thanks,
Barak


On Tuesday, July 22, 2014 5:03:56 PM UTC+3, Matthew Adams wrote:
Please enter an issue for this.  It'd be even better if you can fork the repo, create a failing test case that reproduces this problem, then send a pull request.

I'll have a look as soon as I have time.

-matthew
On Tue, Jul 22, 2014 at 8:12 AM, Barak Cohen <bar...@liveperson.com> wrote:

I am using spring-data-cassandra module.

I have an annotated bean using the @Table annotation and a primary class using the @PrimaryKeyClass

the primary key class has 5 primary key columns (2 partitioned and 3 clustered). 2 of my columns has the name property i.e.:

@PrimaryKeyColumn(name="correlated_type", ordinal = 2, type= PrimaryKeyType.CLUSTERED)
private String correlatedType;

When using the CassandraTemplate insert operation everything is working fine but when i am using the cassandraTemplate.deleteAsynchronously(List<entities> list) the columns name are not parsed using the name property but maintain the field name (correlatedType instead of correlated_type).

i tried using a regular delete operation for a single object and tried to use the forceQuote = true property both didn't help.

insert log sample:
[o.s.cassandra.core.CqlTemplate]     asynchronously executing [INSERT INTO identity_correlations(type,value,"**correlated_type**",ts,"**correlated_value**",extra) VALUES ('Participant','p5','Visitor',4,'R3',{'v':'1','labels':'b,c'}) USING TTL 34128000;

delete log sample:
[o.s.cassandra.core.CqlTemplate]     asynchronously executing [BEGIN BATCH DELETE  FROM identity_correlations WHERE **correlatedValue**='p5' AND **correlatedType**='Participant' AND type='Visit' AND value='v1' AND ts=1;DELETE  FROM identity_correlations WHERE correlatedValue='R3' AND correlatedType='Visitor' AND type='Participant' AND value='p5' AND ts=4;DELETE  FROM identity_correlations WHERE correlatedValue='R3' AND correlatedType='Visitor' AND type='Participant' AND value='p5' AND ts=3;APPLY BATCH;]

did anyone encounter this problem before?


This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein. 
If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.

--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cassandra+unsub...@googlegroups.com.

Matthew Adams

unread,
Jul 29, 2014, 11:21:36 AM7/29/14
to spring-dat...@googlegroups.com, bar...@liveperson.com
Hi Barak,

In the spring-data-cassandra repo, we distinguish between unit tests and integration tests in both modules (spring-cql & spring-data-cassandra), according to Maven best practices.  Unit tests use the Maven Surefire plugin, and integration tests use the Maven Failsafe plugin.  As such, if you issue the command mvn test, you are only running unit tests, which typically don't include any tests that actually touch a Cassandra database.  Further, if you notice the package structure under src/test/java, you'll see that tests are separated into o.s.d.c.t.unit and o.s.d.c.t.integration packages.

To run integration tests, issue the command mvn integrationt-test.  To run a single integration test, mvn integration-test -Dit.test=YourTestClass (to execute all tests in a class) or mvn integration-test -Dit.test=YourTestClass#yourTestMethod (to execute a single test method).  Make sure that you put your integration tests under o.s.d.c.t.integration.

The distinction between surefire & failsafe is, unfortunately, an often overlooked part of Maven.  Please try again to reproduce your errors in your fork and let me know if you need further assistance.

-matthew

Barak Cohen

unread,
Jul 29, 2014, 11:38:24 AM7/29/14
to Matthew Adams, spring-dat...@googlegroups.com
thanks, i will try again.
just a short question. is the Jira the right place to open an issue? (i noticed that you have another one in the github)

Matthew Adams

unread,
Jul 29, 2014, 11:44:25 AM7/29/14
to spring-dat...@googlegroups.com, matthe...@scispike.com
Yes, that's the right place.  I'll double check to see how we take pull requests, because those usually use the github issue tracker.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cassandra+unsubscri...@googlegroups.com.

This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein. 
If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.
Reply all
Reply to author
Forward
0 new messages