I've been hacking at a game for a while and I need a fair amount of data so I use SQLite and store it. Using JDBC directly is somewhat tedious and I was wondering if anyone had any good ORM type libs they recommend for use for games or smallish apps.

I've looked at Hibernate but it's huge and over complicated for my needs.

What we need is something that can automaticlly convert a class into a record in a table, matching field's value and type to table's colomn. That already is available on MVC frmaework such as Play!, but I see no one yet for desktop use.

What we need is something that can automaticlly convert a class into a record in a table, matching field's value and type to table's colomn. That already is available on MVC frmaework such as Play!, but I see no one yet for desktop use.

This is a fairly easy task using reflection. You can pretty much just drop a class and its fields/values into an sql command.

What we need is something that can automaticlly convert a class into a record in a table, matching field's value and type to table's colomn. That already is available on MVC frmaework such as Play!, but I see no one yet for desktop use.

This is a fairly easy task using reflection. You can pretty much just drop a class and its fields/values into an sql command.

I had done it before, but that's not reliable. On Play!, you just let the will-be-persisted class to extends Model and call save() like playerData.save() to persist. The framework will take care everything including table creation. If in next day you add more field, it will also update the schema for you. That's most simple DML related operation that I ever use.

I had done it before, but that's not reliable. On Play!, you just let the will-be-persisted class to extends Model and call save() like playerData.save() to persist. The framework will take care everything including table creation. If in next day you add more field, it will also update the schema for you. That's most simple DML related operation that I ever use.

Interesting but this is also a huge framework 90 MEG! On server side applications size is not so important. For smaller apps and Games we need something tiny that just does the job with little or no dependencies.

I use MyBatis.Pretty simple to use.Pojos with SQL defined in XML and/or in annotations.Can't speak how it deals with more complex requirements - I only save players and scores so far.In compound with JavaDB there is an issue with setting null values, so I might change to HSQLDB.Overall it is definitely worth a look.

You can also do it the other way around - generating record classes from a db-schema. I had some good experience with JOOQ

Yeah JOOQ is interesting but really it emphasizes the query. In many situations especially with games we don't have any complicated queries to worry about. Really I'd prefer just a simple Java Bean and a quick and easy way to read and write it.

I used to insist on using a really "proper" O-R mapper so that JPA or JDO were the only real ways, maybe with MyBatis for complex schemas that just weren't going to map cleanly, but these days I figure anything with actually proper behavior that's at least smart enough to avoid the N+1 selects problem is all good. Mostly it's because I'm finding that directly and transparently mapping entities into domain objects just doesn't work out well for me anyway. Unless it's a DB app first and foremost, there's always some annoying facet of the ORM that's going to get in your way and force you to compromise the design just to satisfy the ORM. Despite all the efforts to paper it over, the "impedance mismatch" is still there and probably always will be.

I currently only have tested bindings to a MySQL db. It should work on every database that supports simple INSERT,SELECT,UPDATE,DELETE queries, because that's pretty much what this wrapper does.

The wrapper is really 'hands off' and non-intrusive, so the database table-design is leading. No effort is made into even storing metadata like @nullable. You'll get a typical SQLException from the server instead if you try to write a null value where it's not allowed.

publicList<Deposit> getDeposits() {// this is so common, that I will probably move the actual query behind a utility method.returnQueryDataObject.selectAll(Deposit.class,"SELECT * FROM deposit WHERE account = ?",this/* varargs: every '?' in the query requires an additional argument */); }}

Depositd = newDeposit(37); // SELECT * FROM deposit WHERE somePrimaryKey = 37// d.account is an instance, but is NOT filled with data, just an identifier, hence:d.account.select(); // SELECT * FROM account WHERE somePrimaryKey = d.account.id()

The DataObject class allows you to override the default names for the tablename and primarykey column.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org