cassandra with Spring Data - java

I'm trying to connect to cassandra database using spring data (preferably jpa). I can not find any clera example how to do it, no guide. I found some for MongoDB and Neo4j, but none for cassandra. On mail page of spring there is a mention of coassandra project but none exmaple or guide is provided. Can any one help?

Which version of spring-data-cassandra are you using?
v.1 https://github.com/spring-projects/spring-data-cassandra v.
v.2 https://github.com/SpringData/spring-data-cassandra
For v.1 see http://docs.spring.io/spring-data/cassandra/docs/1.1.0.RC1/reference/html/#cassandra-connectors
I'm using v.2 and also had problems with finding tutorials/examples. But there are test inside the lib itself. See eg. spring-data-cassandra/cassandra/src/test/resources/org/springdata/cassandra/test/integration/config/XmlConfigTest-context.xml - you need to change only few things to make it work with your DB. When cofig is ready you can use CqlOperations to run your queries:
#Autowired
private CqlOperations cassandraTemplate;
cassandraTemplate.buildSaveNewOperation(new Foo("bar")).execute();
And that's basically it :)

I used spring-data-cassandra-1.1.2.RELEASE. Here are 2 links which provide you detailed steps to configure Cassandra with Spring Data: link1 and link2.
I followed the XML configuration way mentioned in link2, but faced one problem. I guess the ticket for this problem is here and is still open. This problem was resolved by just removing the id attribute from <cassandra:template id="cassandraTemplate" />. This code is from the config xml shown in the section 4.3.2 of link2.
Apart from this I did not face any problems and the Spring data Cassandra integration worked fine.
Section 5.1 from this link can also be used.

Related

Camunda BPM - migration from 7.14.0 to 7.18.0

I'm trying to upgrade Camunda version in one of my current Spring Boot projects - from 7.14.0 to 7.18.0.
I've changed the versions of Camunda libs and from the application perspective everything works great, but I'm concidering If I should also make some changes in the database schema to avoid problems with past non-finished processes?
I've read camunda docs and found the latest patch: 'engine_7.14_patch_7.14.2_to_7.14.3.sql'
https://docs.camunda.org/manual/7.18/installation/database-schema/#liquibase-patch-level-update
https://jira.camunda.com/browse/CAM-12832
Does it mean that after version 17.4.3 db schema stays the same?
If not can someone provide me some tips where can I find any informations about the migrations steps?
Pleas efollow
https://docs.camunda.org/manual/7.18/update/minor/714-to-715/
https://docs.camunda.org/manual/7.18/update/minor/715-to-716/
https://docs.camunda.org/manual/7.18/update/minor/716-to-717/
https://docs.camunda.org/manual/7.18/update/minor/717-to-718/
to get from 7.14 to 7.18.

HSQLDB persistence in a Spring project

I checked a lot of answers but I didn't understand most of them, so please bear in mind that I'm very new to programming and Java.
So, I was following this tutorial: https://medium.com/#fsonmezay/restful-issue-tracking-application-with-spring-boot-and-angularjs-61b69537b10e
But as noted in that, everything I do on the UI while the app is running disappears when I close the app.
It uses HSQLDB as the database manager, and I need the app to write on the database everything that I add while it is running.
Also, don't know if it's worth mentioning but instead of using maven, I'm using Gradle.
By default, Spring Boot autoconfigures in-memory HSQLDB connection, so all data obviously will be lost. You need to provide spring.datasource.url configuration property to override automatic configuration and use persistent data connection, for example spring.datasource.url=jdbc:hsqldb:file:~/mydb property will store your data into ~/mydb file. Take a look at Spring Boot documentation for more information on data source autoconfiguration and HSQLDB documentation for more information about HSQLDB configuration properties.

JAVA Dropwizard configuration for Neo4j ogm

I'm building a project in JAVA with Dropwizard and are looking to start using Neo4j as database. I have been looking on a lot of different options and think that the spring-data-neo4j lib looks like a good solution.
However, since I haven't been working with Spring earlier, I'm having a hard time figuring out how to setup the configuration classes in order to start building repositoris/DAO's.
I have found a tutorial for integrating springs MySQL-driver, but while reading through the documentation for springs neo4j-driver, I noticed that the neo4j-driver doesn't seem to use the DataSourceFactory establishing a connection.
Anyone have any idea on how to proceed?
Thanks in advance!

Hibernate 4 second level cache with memchached

I have a spring application on heroku (seems like there is no way to use ehCache there). I found several projects on github like hibernate-memcached for the second level cache, but they have just few stars on github and I'm not sure if they are not buggy.
Would you recommend anything for java + hibernate 4 second level cache based on memcached?
https://github.com/kwon37xi/hibernate4-memcached
I made this.
One of heroku user sent me an email that he was using this library.
I have never been used heroku, but anyway I think this library work fine with heroku.
I heard heruku memcached requires authentication, refer to this wiki page https://github.com/kwon37xi/hibernate4-memcached/wiki/SpyMemcachedAdapter about authentication.

Play Framework 1.2.6 connect multiple database

I am able to connect to my default database. But added to that I also want to connect another database. I am using Play Framework 1.2.6. I know that this support is present in the main branch of Play 1.2.x. Can any one please help me, how I can achieve this in 1.2.6.
Thank you
Play 1.2.6 (or the 1.2.x branch) doesn't support multiple database connections out of the box.
This support will be available in Play 1.3 which has not been released yet.
Here is the according ticket from the Play bug tracker:
http://play.lighthouseapp.com/projects/57987-play-framework/tickets/706
What database are you using? If your database supports multiple schemas you can achieve what you want by adding the following line on top of class.
#Entity
#Table(name="<table_name>",schema="<schema_2>")
public class xxx extends Model {
Entity and Table are part of the persistence api.
Found another interesting solution to your problem. Use below link if you need occasional access to the second database.
click here
You can try to use this module : http://www.playframework.com/modules/multidb
Aj.

Categories

Resources