helenus/README.md

62 lines
1.1 KiB
Markdown
Raw Normal View History

2015-03-12 00:57:13 +00:00
# casser
2015-03-24 03:47:16 +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);
CasserSession session = Casser.init(getSession()).showCql().createDrop(Timeline.class).get();
```
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
```