Support Map for Cassandra #219

Closed
szarnyasg opened this Issue Mar 20, 2013 · 4 comments

5 participants

@szarnyasg

Please support Map objects for Cassandra (as mentioned at https://groups.google.com/forum/?fromgroups=#!topic/kundera-discuss/fz02b7S1Aa4).

For example, the following entity should be mapped to Cassandra.

@Entity
@Table(name = "PERSONNEL", schema = "KunderaExamples@cassandra")
public class Personnel {
    @Id
    @Column(name = "PERSON_ID")
    private String personId;

    @Column(name = "MAP")
    private Map<String, String> map = new HashMap<>();

    public Map<String, String> getMap() {
        return map;
    }

    public void setMap(Map<String, String> map) {
        this.map = map;
    }
}
@mevivs
Collaborator

Just to add on this.

MongoDB API provides serialization deserialization support of map object. However Cassandra APIs does not provide any such support. So it means enabling such features in Cassandra would require Kundera to handle it explicitly.

-Vivek

@pires

Why don't you just go with a List of Embeddable objects with two String members? Something like:

@Embeddable
public class MyMap {
  String attr1, attr2;

  // getters and setters
  //...
}

@Entity
@Table(name = "PERSONNEL", schema = "KunderaExamples@cassandra")
public class Personnel {
    @Id
    @Column(name = "PERSON_ID")
    private String personId;

    @ElementCollection
    @CollectionTable(name = "MAP")
    private List<MyMap> map = new ArrayList<MyMap>();

    // getters and setters..
}

Or use composite columns.

@mevivs
Collaborator

👍
Support needs to be added for all collection types. Please refer :

http://cassandra.apache.org/doc/cql3/CQL.html#collections

-Vivek

@mevivs mevivs was assigned Jul 17, 2013
@xamry

Support for all collection types has been implemented in kundera-cassandra and is available in trunk branch.
This will be released with 2.7.
Please see:
https://github.com/impetus-opensource/Kundera/blob/trunk/kundera-cassandra/src/test/java/com/impetus/client/crud/collection/BlogPostTest.java

A wiki page will be published later before release.

@kkmishra kkmishra closed this Aug 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment