{% extends "base.html" %} {% block body %}

Welcome to siena project!

Siena is a persitence API for Java inspired on the Google App Engine Python Datastore API. Example usage:

List<Employee> someEmployees = Employee.all()
		.filter("firstName", "Mark")
		.order("-lastName")
		.fetch(10);

Siena is a single API with many implementations. You can use siena with relational databases, with the Google App Engine's datastore or with Amazon's SimpleDB. There is also an implementation called siena-remote very useful if you want to use the Google App Engine's datastore remotely. Other implmenetations are planned such as: HBase, DBSLayer,...

Siena is Open Source and is released under the Apache License 2.0.

Advanced features

Siena has several features including built-int JSON support for easily storing complex data structures in a single field. It also has automatic queries and database schema creation / synchronization for relational databases.

import siena.*;
import static siena.Json.*;

@Table("employees")
public class Employee extends Model {
	
	@Id(Generator.AUTO_INCREMENT)
	public Long id;
	
	@Column("first_name")
	@Max(200) @NotNull
	public String firstName;
	
	@Column("last_name")
	@Max(200) @NotNull
	public String lastName;
	
	@Column("contact_info")
	public Json contactInfo;
	
	@Column("boss") @Index("boss_index")
	public Employee boss;
	
	@Filter("boss")
	public Query<Employee> employees;
	
	public static void main(String[] args) {
		Employee e = new Employee();
		e.firstName = "John";
		e.lastName = "Smith";
		e.contactInfo = map()
			.put("email", "john.smith@example.com")
			.put("telephone", list("xxx", "yyy"));
		e.insert();
		
		System.out.println(e.contactInfo);
	}
	
	public static Query<Employee> all() {
		return Model.all(Employee.class);
	}

}

This example shows a class with an auto-increment primary key, some simple fields, a field called contactInfo that may will contain a complex data structure and finally there is a special employees field that will let query those employees whos boss is the current employee. The main() method creates a new Employee and prints its contact info. This is the output:

{"email": "john.smith@example.com", "telephone": ["xxx", "yyy"]}

The example also shows how to use some annotations such as @NotNull or @Index that will be used to generate the database schema if you are using a relational database.

The all() method is not mandatory but is strongly recommended.

Now that you have taken a brief look at what Siena does it's time to read the Getting started guide.

{% endblock %}