Hot questions for Using Cassandra in hibernate

Question:

I have two class and I want to use OneToMany relation with EmbeddedId (Im working with kundera framework) my sensor entity class:

public class SensorEntitie implements Serializable {
    @EmbeddedId
    private CompoundKey key;
    @Column
    private float temperature;
    @Column
    private float pressure;

    @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
    @JoinColumn(name="what I should to put here")
    private List<PieceEntitie> pieces;
}
@Embeddable
    public class CompoundKey
    {
        @Column 
        private String IdSensor;           
        @Column 
        private long date;           
        @Column(name = "event_time")
        private long eventTime;

my piece class entity

public class PieceEntitie implements Serializable{

    /**
     * 
     */
    @Id
    private String IdPiece;
    @Column
    private double width;
    @Column
    private double height;
    @Column
    private double depth;

but how can i fill the blank in @JoinColumn


Answer:

I found the solution : to use OneToMany relation with EmbeddedId, I should to declare JoinColumns and multiple of JoinColumn

@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
    @JoinColumns({
        @JoinColumn(name = "idsensor", referencedColumnName = "idsensor"),
        @JoinColumn(name = "date", referencedColumnName = "date"),
        @JoinColumn(name = "event_time", referencedColumnName = "event_time")
})

Question:

I want to create a relationship between my sensor class with pieces class using kundera as a framework and cassandra as my database:

what Im trying to do is: each sensor is associate to many pieces :

sensor 1____0 * pieces

but after doing this configuration (below), I get two separate table without any relation like this:

 idsensor | date  | event_time               | pressure | temperature
----------+-------+--------------------------+----------+-------------
        1 | 33544 | 1970-01-01 00:00:00+0000 |       10 |          10

(1 rows)
cqlsh:sensor> select * from pieces;

 idpiece | date | depth | event_time | height | idsensor | sensorkey | width
---------+------+-------+------------+--------+----------+-----------+-------
       1 | null |    12 |       null |     11 |     null |      null |    10

key class:

@Embeddable
public class SensorKey
{
    @Column 
    private String idsensor;           
    @Column 
    private long date;           
    @Column(name = "event_time")
    private long eventTime;

sensor class

   public class SensorEntitie implements Serializable {
    @EmbeddedId
    private SensorKey sensorkey;
    @Column
    private float temperature;
    @Column
    private float pressure;
    @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
    @JoinColumns({
        @JoinColumn(name = "idsensor", referencedColumnName = "idsensor"),
        @JoinColumn(name = "date", referencedColumnName = "date",
            insertable = false, updatable = false),
        @JoinColumn(name = "event_time", referencedColumnName = "event_time",
            insertable = false, updatable = false)
})
    private Set<PieceEntitie> pieces;

pieces class:

public class PieceEntitie implements Serializable{


    @Id
    private String idpiece;
    @Column
    private double width;
    @Column
    private double height;
    @Column
    private double depth;

tutorial followed; https://github.com/impetus-opensource/Kundera/wiki/Polyglot-Persistence

how can i create this relation ?


Answer:

Problem resolved after using Cassandra 3

because before I used cassandra 2.1

Question:

i just wrote a testing programm for multiple Databases. It is based on hibernate vor relational databases and hibernate-ogm for NoSQL databases.

at the moment I support mysql, postgresql and MongoDB. Now I wanted to try out the cassandra driver, but I get the error:

'cassandra_experimental' is no valid datastore provider short name. Valid values are: MAP, INFINISPAN, EHCACHE, MONGODB, NEO4J_EMBEDDED, COUCHDB_EXPERIMENTAL

my dependency list in my maven project:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-bom</artifactId>
            <version>4.2.0.Final</version>
        </dependency>

    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>org.jboss.jbossts</groupId>
        <artifactId>jbossjta</artifactId>
        <version>4.16.6.Final</version>
    </dependency>



    <!-- Hibernate Search -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-search-orm</artifactId>
        <version>5.0.1.Final</version>
    </dependency>

    <!-- Use this for MongoDB -->
    <dependency>
        <groupId>org.hibernate.ogm</groupId>
        <artifactId>hibernate-ogm-mongodb</artifactId>
        <version>4.1.3.Final</version>
    </dependency>


    <!-- cassandra -->
    <dependency>
        <groupId>org.hibernate.ogm</groupId>
        <artifactId>hibernate-ogm-cassandra</artifactId>
        <version>4.2.0.Final</version>
    </dependency>

    <!-- mysql -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.36</version>
    </dependency>

    <!-- postgresql -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1200-jdbc41</version>
    </dependency>

    <!-- Testing -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.easytesting</groupId>
        <artifactId>fest-assert</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
</dependencies>

I use the hibernate documentation docs.jboss.org

Has someone usesd cassandra already and can give some advice here?

I appreciate any answer :)

PS: some more information: I use a windows 7 client and an ubuntu 14.04 server in a virtual machine. on my client I use eclipse kepler to write my programm.

edition: I was asek for the error messages when I remove the version in the pom.xml:

mvn eclipse:eclipse
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.hibernate.ogm:hibernate-ogm-mongodb:jar is missing. @ line 49, column 15
[ERROR] 'dependencies.dependency.version' for org.hibernate.ogm:hibernate-ogm-cassandra:jar is missing. @ line 56, column 15
 @
 [ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.hibernate.demos:History_Log_Test:1.0-SNAPSHOT (C:\User
s\MOTZA\Documents\__BA\Bachelor-Thesis\ws\History_Log_Test\pom.xml) has 2 errors

[ERROR]     'dependencies.dependency.version' for  org.hibernate.ogm:hibernate-og
m-mongodb:jar is missing. @ line 49, column 15
[ERROR]     'dependencies.dependency.version' for org.hibernate.ogm:hibernate-og
m-cassandra:jar is missing. @ line 56, column 15
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildin
gException

Answer:

Can you remove the versions of the hibernate-ogm-mongodb and hibernate-ogm-cassandra dependencies, you will get them from the BOM:

<dependency>
    <groupId>org.hibernate.ogm</groupId>
    <artifactId>hibernate-ogm-mongodb</artifactId>
</dependency>

<dependency>
    <groupId>org.hibernate.ogm</groupId>
    <artifactId>hibernate-ogm-cassandra</artifactId>
</dependency>

You specify 4.1.3 for hibernate-ogm-mongodb, maybe this pulls in the older version of hibernate-ogm-core. If it still doesn't work, some more details around your environment are needed: Is this Java SE or on a JJ server such as WildFly?