Skip to main content

Easy-Cassandra 1.0.9 Final : With annotations inheritance, jpa and JPQL

Posted by otaviojava on May 26, 2012 at 8:40 AM PDT

Release the newest version of the framework to persist objects in Apache Cassandra in easy way. Among improvement is the JPA annotations, also JPQL.

  JCassandra jCassandra=persistence.createJCassandra("select * from Person");
 List persons=jCassandra.getResultList();

table 1: sample using JPQL in Easy-Cassandra

This version has the improvements below:

    Supporting at jpa 2.0 annotation
    Query with objects
    Version to retrieve the timestamp of the object
    Using the JPQL
    now supported inheritance


Easy-Cassandra 1.0.8
Easy-Cassandra 1.0.9 (Com JPA anotação)
org.easycassandra.annotations.ColumnFamilyValue

javax.persistence.Entity
org.easycassandra.annotations.ColumnValue
javax.persistence.Column
org.easycassandra.annotations.EmbeddedValue
javax.persistence.Embedded
org.easycassandra.annotations.EnumeratedValue
javax.persistence.Enumerated
org.easycassandra.annotations.KeyValue
javax.persistence.Id
org.easycassandra.annotations.KeyValue equals
true
javax.persistence.GeneratedValue
org.easycassandra.annotations.IndexValue
org.easycassandra.annotations.Index

Also was added functionality for the @Version annotation, its objective is see the timestamp common between fields in objects.

@Entity(name = "autocount")

public class Count implements Serializable {



    private static final long serialVersionUID = 3L;

    

    @Id

    @GeneratedValue

    private BigInteger id;

    

  

    @Column(name = "name")

    private String name;

    

    @Version

    private Long timeStampLong;



    @Version

    private Date timeStampDate;

    

    @Version

    private Calendar timeStampCalendar;



//getter and setter

}

table 3: using the Version annotation

Also you can use inheritance for this you need the @MappedSuperclass annotations in father's class and the subclass allow persist the objects of the super class.

@MappedSuperclass
public class Worker implements Serializable {

private static final long serialVersionUID = -5568409094833637814L;

@Column
private String name;

@Column
private Double salary;
//getter and setter

@Entity
public class Engineer extends Worker {
@Id
private String nickName;

@Column
private String type;

@Column
private String especialization;

//getter and setter
}