K.E.
K.E.

Reputation: 838

Kundera cassandra - lightweight transaction in merge method

I am using kundera-cassandra V3.2 and want to update an entity with the method merge.

this.getManager().merge(entity); // this.getManager is a javax.persistence.EntityManager

Is there a possibility to use a lightweight transaction (IF clause) when calling this method or do I have to create a update query manually?

Upvotes: 0

Views: 114

Answers (1)

karthik manchala
karthik manchala

Reputation: 13640

In Kundera, lightweight transactions are supported through createNativeQuery method. There is no direct method for merging with lightweight transactions.

Sample code:

String query = "UPDATE \"PERSONCASSANDRA\" SET \"PERSON_NAME\" = 'Pragalbh' WHERE \"PERSON_ID\" = '4' IF \"PERSON_NAME\" = 'Karthik'";
Query q = entityManager.createNativeQuery(query, PersonCassandra.class);
q.executeUpdate();

Please check this test-case for more information.

Upvotes: 2

Related Questions