views:

221

answers:

2

I'm working on a medium-sized project in Java (GWT to be precise), and I'm still in the process of deciding what ORM to use.
I just refuse to write SQL queries unless utterly and completely necessary (not the case :D)

I want to use ONLY annotations, no XML configuring [except database location, username, etc], and I DON'T want to create any tables or define them. I want this to be done by the framework completely.
Call me lazy, but I like Java/GWT programming, not creating tables and coping with that sort of things, and it's a plus in my assignment if I actually use an ORM :D

I've considered so far:

  • Hibernate with annotations: I've found little documentation to get started from ground using this. I've found little examples and alike. It's as if they didn't actually want you to use 100% annotations.
  • DataNucleus
    • JDO: It seems interesting, I'd never heard of DataNucleus up to until this week, but it seems extremely mature, and I actually discovered it because Google uses it in GWT, so that's a good sign. I also like the fact that they mentioned I don't need to define any tables or columns, though I think hibernate can achieve this as well. I actually enjoyed reading though their documentation (though I haven't finished yet), something quite opposite to hibernate.
    • JPA I'm not totally sure if DataNucleus/JPA can work with annotation-only configuration, though I might need to take a deeper look into the documentation.

As you might guess, I'm quite inclined to JDO... but it'd be nice to hear what people who've used it have to say vs the other alternatives, and if i'm missing some very important point here.

Edit 1: I know I'll need to XML the database location/usr/pwd, I meant I don't want to use an XML to configure the mapping or database schema.

+4  A: 

JPA (1 and 2) is pretty much XML free, depending on how it's packaged. You most certainly don't need it for the schema. It also supports annotations for details when the tables are generated.

The only issue with these is that while they can create a database, they're a DB MAPPING tool, not a DB DEFINITION tool. Specifically, most won't allow you to create the arbitrary indexes that you may well need to get the DB tuned properly to your queries.

But other than that, JPA should fill your needs, and it has a lot of implementations (Hibernate is just one implementation).

Will Hartung
I was specifically referring to DataNucleus' JPA implementation, but it's good to know that JPA in general suits my need. I don't quite understand what you meant in the second paragraph, what in particular can't it do? :/
Hugo
In databases, you can define (amongst other things) indices on columns you might frequently use when retrieving data. This has considerable performance benefits.
Adam Luchjenbroers
Oh, yup, I know what they are heh :) Hadn't understood before, thanks :)
Hugo
A: 

This is a self publicizing but I'm been working for a while on a simple Java ORM package called ORMLite. I wanted something much less complicated than hibernate but without writing SQL directly. It's completely annotation based and currently supports MySQL, Postgres, Derby, and H2. Adding other database would be simple if I have access to a server. It is completely annotation based and can create (and destroy) tables.

It has pretty flexible QueryBuilder and table paging. Joining is, however, not supported. Here's its sourceForge project. Jar, source-jar, documentation, and javadocs are there.

Love to get some feedback on it.

Gray
I'll give it a try some time this week and give you some feedback :) Though I'm not sure if I can go through with my project without some complex criteria.
Hugo
I've added complex where criteria to the package. Does not support joining however.
Gray