|
Sponsored Links
Resources
Enterprise Java Research Library
Get Java white papers, product information, case studies and webcasts
|
News
News
News
|
Messages: 13
Messages: 13
Messages: 13
Printer friendly
Printer friendly
Printer friendly
Post reply
Post reply
Post reply
XML
XML
XML
|
 |
Siena: the scalable persistence tier for Java
Siena is a persitence API for Java inspired on the Google App Engine Python Datastore API. This is an example of 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 (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.smith@example.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.smith@example.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.
|
|
Message #322188
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA compliant
Nice work. love to try it out. Only I would rather see it implement the jpa spec then this custom standard.
m2c
|
|
Message #322190
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: JPA compliant
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
|
|
Message #322191
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
It doesn't implement JPA
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.
|
|
Message #322195
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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
|
|
Message #322198
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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!
|
|
Message #322201
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: It doesn't implement JPA
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.
|
|
Message #322239
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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.
|
|
Message #322243
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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.
|
|
Message #322251
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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.
|
|
Message #322298
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: It doesn't implement JPA
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.
|
|
Message #322301
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Siena: the scalable persistence tier for Java
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!
|
|
Message #322435
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Associations
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
|
|
Message #322439
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Associations
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:
|
|
 |
New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com |
 |
 |
Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6.
(November 2, Article)
SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options.
(September 28, Article)
Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team.
(September 22, Article)
Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies.
(July 14, Article)
JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags.
(June 29, Article)
In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project.
(June 23, Tech Talk)
Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now.
(June 15, Tech Talk)
In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements.
(June 15, Tech Talk)
In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls.
(June 4, Tech Talk)
Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable.
(May 28, Tech Talk)
This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work.
(May 26, Tech Talk)
Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers.
(May 21, Tech Talk)
Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application.
(May 19, Article)
In this session Nati Shalom demonstrates how to take a standard Java EE web application and scale it out or down dynamically without changes to the application code. Seeing as most web applications are over-provisioned to meet infrequent peak loads, this is a dramatic change because it enables growing your application as needed, when needed, without paying for unutilized resources.
(May 19, Tech Talk)
Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)
The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)
|
|