helenus/README.md

62 lines
1.2 KiB
Markdown
Raw Normal View History

2015-03-26 03:33:19 +00:00
# casser ![build](https://travis-ci.org/noorq/casser.svg?branch=master)
2015-03-26 02:31:25 +00:00
Java 8 Cassandra Client
2015-03-12 08:08:42 +00:00
2015-03-18 03:17:44 +00:00
### Features
* Leverages Java 8 language capabilities to build CQL queries
* Simple function-style API
2015-03-12 08:08:42 +00:00
### Requirements
* Only JVM 8
* Datastax Driver
* Maven
2015-03-24 04:38:53 +00:00
### Example
2015-03-24 04:42:56 +00:00
Entity definition:
2015-03-24 04:38:53 +00:00
```
2015-03-24 04:42:56 +00:00
@Table("timelines")
public interface Timeline {
@PartitionKey
UUID getUserId();
void setUserId(UUID uid);
@ClusteringColumn
@DataTypeName(Name.TIMEUUID)
Date getTimestamp();
void setTimestamp(Date ts);
@Column
String getText();
void setText(String text);
}
```
Session initialization:
```
Timeline timeline = Casser.dsl(Timeline.class);
2015-03-25 04:58:58 +00:00
CasserSession session = Casser.init(getSession()).showCql().add(Timeline.class).autoCreateDrop().get();
2015-03-24 04:42:56 +00:00
```
Select information:
```
session.select(timeline::getUserId, timeline::getTimestamp, timeline::getText)
.where(timeline::getUserId, "==", userId)
.orderBy(timeline::getTimestamp, "desc").limit(5).sync()
.forEach(System.out::println);
```
Insert information:
```
Timeline post = Casser.pojo(Timeline.class);
post.setUserId(userId);
post.setTimestamp(new Date(postTime+1000L*i));
post.setText("hello");
session.upsert(post).sync();
2015-03-24 04:38:53 +00:00
```