1
votes

I want to use the a sequence generator in an kundera-cassandra (V3.2) entity. Referring to this https://github.com/impetus-opensource/Kundera/issues/777 I have to set the CQL Version to Version 3 when creating the EntityManagerFactory, and not when creating the EntityManager. My Problem is that I use Spring and I do not know how to set the property when autowiring the EntityManagerFactory.

@Id
@TableGenerator(name = "id_gen", allocationSize = 30, initialValue = 100)
@GeneratedValue(generator = "id_gen", strategy = GenerationType.TABLE)
private String id;

In my Repository i define the EntityManagerFactory like this:

@PersistenceUnit
private EntityManagerFactory entityManagerFactory;

And in my application-context.xml I define the Bean like this:

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="cassandra_pu" />
</bean> 

<bean id="pum" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
    <property name="persistenceXmlLocations">
        <list>
            <value>classpath:persistence.xml</value>
        </list>
    </property>
</bean>

So can anybody tell my where to set the version-property?

1

1 Answers

1
votes

You can do the following:

  • Create an xml file say cass-props.xml and add the following:

<?xml version="1.0" encoding="UTF-8"?> <clientProperties> <datastores> <dataStore> <name>cassandra</name> <connection> <properties> <property name="cql.version" value="3.0.0" /> </properties> <servers> <server> <host> localhost </host> <port> 9160 </port> </server> </servers> </connection> </dataStore> </datastores> </clientProperties>

  • Then add the following property in your persistence.xml

    <property name="kundera.client.property" value="cass-props.xml" />