Siena: the scalable persistence tier for Java

Discussions

News: Siena: the scalable persistence tier for Java

  1. Siena is a persitence API for Java inspired on the Google App Engine Python Datastore API. This is an example of usage: List 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 (using JDBC as underlying persistence mechanism), but you can also use it 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 implementations are work in progress such as: HBase and DBSLayer. If you want to use Siena in a relational database it will help you to keep your database schema synchronized with your persistent classes. You just need to add some annotations such as @Table, @Column, etc. Siena also comes with built-in support for JSON so you can easily store complex data structures in one field in the database. Example: Employee e = new Employee(); e.firstName = "John"; e.lastName = "Smith"; e.contactInfo = map() .put("email", "john dot smith at example dot com") .put("telephone", list("xxx", "yyy")); e.insert(); The "contactInfo" field has been defined as a field of type siena.Json. This is how that field is formated into the database: {"email": "john dot smith at example dot com", "telephone": ["xxx", "yyy"]} The parsing and formatting of the Json fields is done in a transparent way. You don't need to worry about that :) If you are interested on using Siena in your project take a look at the Getting started guide. Siena has a small footprint (a few Kbytes) and has very few dependencies: * Siena for relational databases depends only on JDBC and your JDBC driver. If you want to synchronize the database schema you need also Apache DdlUtils. * Siena for Google App Engine just depends on GAE. * Siena for Amazon's SimpleDB has no dependencies. * Siena-remote just depends on dom4j * Siena for HBase just depends on HBase. We are planning to release a 1.0 version this year, but we want people to use it and give us feedback.

    Threaded Messages (13)

  2. JPA compliant[ Go to top ]

    Nice work. love to try it out. Only I would rather see it implement the jpa spec then this custom standard. m2c
  3. Re: JPA compliant[ Go to top ]

    Nice work. love to try it out.
    Only I would rather see it implement the jpa spec then this custom standard.

    m2c
    Well, a custom standard is an oxymoron. Guido
  4. It doesn't implement JPA[ Go to top ]

    Siena doesn't implement JPA. The API has been designed without following any standard. It is inspired on the Google App Engine Python Datastore API.
  5. Re: It doesn't implement JPA[ Go to top ]

    Siena doesn't have to implement JPA. DataNucleus for Google App Engine (GAE) Datastore use JPA, but as you see the feature would be non-standard too. JPA created for RDBMS, expected to have SQL features such as using operator like "and", "or", ">", "<"not", there is no such thing on GAE Datastore API. So when you want to create GAE application and has possibilities that someday you'll switch to RDBMS, Siena might not a bad idea.
  6. Siena doesn't implement JPA. The API has been designed without following any standard. It is inspired on the Google App Engine Python Datastore API.
    Thanks God. I still need to understand the need to use that awfully lame API.
  7. So if I want a class to be usable by this software I have to tie it to your classes, and can't have a method on my class called "insert()" for example, and various other methods ? Seems a bit intrusive IMHO, not able to just provide a POJO and persist it. Why not compare it with existing standards (JDO, JPA) and suggest why somebody would want to use it ? Doesn't mean it doesn't contain good ideas, just you have to put it in the context of a developer using current technology and show them why they would want to
  8. Hi Andy! The main goal of Siena is simplicity. I liked the idea of having the CRUD methods in the same class than your model class. The easiest way to do that was having a superclass with that methods so when you subclass it you inherit those methods. There is another (not very important) advantage of using inheritance. You can easily calculate fields on updates and inserts. For example: public void insert() { this.creationDate = new Date(); this.totalPrice = this.price + this.taxes; super.insert(); } Why don't user inheritance? It is basic OO design. You can't make a custom insert() method, but it really matters? Your model classes depend on a third-party library, but does it really matters if you will rewrite the whole application if you decide to change the persistence API you are using? I think the main difference between JPA or JDO and Siena is its simplicity, and other features like "automatic-queries" and the built-in JSON support. Thanks for your comment!
  9. Why don't user inheritance? It is basic OO design. You can't make a custom insert() method, but it really matters?
    It may be basic, but is not good OO design. Extending a class merely to add it's methods to another class is not OO. It's pseudo-O. There's clearly no need to add the all method to your class and unless you expect people to override insert, update, etc. there's no reason to have those on the class either. This is not nit-picking. By making people extend your class, you are creating a lot of issues for your users and for what? So you can label it as OO? You might have a really good tool here but I would strongly encourage you to eliminate any unnecessary inheritance requirements.
  10. Well, actually Model.insert() is just a shortcut method to the configured PersistenceManager insert() method, so I could remove the inheritance requirement but I don't see what are those issues of using inheritance.
  11. Well, actually Model.insert() is just a shortcut method to the configured PersistenceManager insert() method, so I could remove the inheritance requirement but I don't see what are those issues of using inheritance.
    Well the one obvious issue in Java is that you can't inherit from more than one parent. Your users might need to inherit from another class for reasons that have nothing to do with your framework and that you can't predict. But more than anything, if there's no need for it, why impose this constraint on your users? This: object.insert(); Isn't much more convenient than this: foo.insert(object); And in the long run, experienced developers will have the second anyway so that they can keep things in one place instead of having to find tons of insert calls on different types strewn throughout the code. You could make extending optional. I don't think many people would fault you for that.
  12. I have made some changes and I have removed totally the need of extending the Model class. There is a new release available to download and I have updated a section of the Getting started guide (Working with single objects). Thanks for your comments!
  13. Associations[ Go to top ]

    How are associations handled with siena? I can add fields which correspond to the fk, but how are the objects then loaded (and stored in corresponding transient fields)? Can I overwrite methods which are called before storing (for setting the fk) or after loading (for loading the referenced object)? And if yes, are these methods also called in case of a fetch? Thanks, Dominik
  14. Re: Associations[ Go to top ]

    Hi! Siena will handle the foreign keys by you. Example: class Company { @Id public long id; public String name; } class Employee { @Id public long id; public String name; @Column("company_id") // this is the foreign key column name public Company company; } If you query an Employee: Employee e = Employee.all().....get(); e.company.id is loaded, e.company.name is not loaded. You can load the whole object by doing e.company.get() If your object has more than one primary key, then you will put more than one String into the @Column annotation: @Column({"fk1", "fk2"}) You can join the discussion group to ask more questions: