Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is cayenne good choice for my requirement? [closed]

We are evaluating ORM solutions for my project that has tight coupling between business layer and datalayer(JDBC). I started doing a PoC with Cayenne. My requirement goes like this a) Already there exists database schema b) Schema is very granular level. I.e. real time java objects are only derived by combining tables. c) At the moment I just want to perform read operation (to be precise filter and sort on a list by inputing criteria)

Till now, the observations I have made with Cayenne are 1) Table and Object are tightly coupled. Modeler is not allowing to create java object without associated table. 2) I could not find easy way to map output of a named query to a java object so that I get list in a way application needs. 3) Also I am not sure Expressions work with named queries.

I would like to know your inputs on best choice for my requirement?

Thank you in advance.

like image 657
Sudheer Avatar asked Feb 25 '10 13:02

Sudheer


2 Answers

If I had to choose an ORM tool or a JPA provider, it wouldn't be Cayenne simply because it doesn't seem to be widely used so the community behind it isn't very large and this is a concern. There is thus no need to discuss technical points, things like Cayenne 2.0 is intrusive, you have to implement an interface or to extend a superclass (Cayenne 3.0 has POJO support but is still in beta, after more than 2 years...). No, really, I don't see any good reason to not pick Hibernate, the defacto standard, if you need an ORM tool.

But...

Given your requirements, an ORM might actually not be the best choice, mosty because of b) so I would consider using iBatis (which is not an O/R mapper, it's a data mapper) instead.

like image 119
Pascal Thivent Avatar answered Sep 20 '22 00:09

Pascal Thivent


Cayenne has a lot of very good features, and on the plus side you have a number of open source tools to use in your project. Hibernate suits some people and Cayenne others. I know that for more own use, Cayenne was far superior to Hibernate due mainly to these factors:

  • a very helpful user community. Hibernate's can be a little abrasive.
  • a very robust code base with a large number of tests which provide large code coverage
  • ROP (three tier) support. This in itself is a huge feature if you need it.
  • good inheritance support
  • Cayenne modeler

Yes, the Cayenne approach is that Object Entities (the Java clients which map to the db) extend a superclass. That gives you some distinct advantages over Hibernate (Cayenne controls the entire object lifecycle) and introduces complexities for some people.

I also find the way Cayenne manages the Context (a group of objects and changes which will later be committed together) to be very intuitive.

As for your questions:

1) Cayenne definitely lets you create Object Entities without a one-to-one map to a table. We do it all the time, particularly when modelling inheritance.

2) SQLTemplate will let you get at named queries, but you'll find that most ORMs will steer you away from this approach since you are working against the natural way an ORM works to build queries directly in the database. The point is to abstract the database whenever possible.

3) SQLTemplate will let you do just about anything you want. But again, adopting an ORM is about a strategy for writing your application, not just a light wrapper for JDBC. I believe the benefits are huge and our projects have benefitted, but it depends on your goals.

like image 22
Ari Maniatis Avatar answered Sep 19 '22 00:09

Ari Maniatis