kundera icon indicating copy to clipboard operation
kundera copied to clipboard

How to prevent duplicate inserts with em.persist (CQL : IF NOT EXISTS)

Open sohelmk opened this issue 6 years ago • 1 comments

Hi, When we try to persist same entity with em.persist it does not throw an exception. Probably this is default cassandra behaviour with CQL also, it just updates if row exist. But CQL does offer IF NOT EXISTS clause to check this. How can we achieve same using Kundera?

Thanks, Sohel Khan

sohelmk avatar Jun 27 '18 08:06 sohelmk

Hi @sohelmk,

You can use entityManager.createNativeQuery().

Check testcase for details.

devender-yadav avatar Jun 29 '18 11:06 devender-yadav