Hi all,
Based on a discussion here I thought I would post my ORM library for Java. Have a look at Persism. http://persism.sourceforge.net
Persism is a simple no-nonsense, auto-configuration, auto-discovery, convention over configuration Object Relational Mapping library. Persism uses POJOs for data objects and does not need any XML for configuration. Annotations are only used as a fall-back in cases where the library can’t discover the mapping on it’s own. Persism is pretty smart so you usually don’t need to bother with annotations at all.
Persism has no external dependencies however it will use logging if available and it’s only about 40k.
Persism has only 2 classes: Query for reading data and Command for updates/inserts and deletes.
The library works around the Connection object. Example of a query:
Query query = new Query(connection);
List<Player> list = query.readList(Player.class,"select * from PLAYERS where name = ?", "Fred");
// or a single object
Player fred = query.read(Player.class,"select * from PLAYERS where name = ?", "Fred");
// or even simpler
Player fred = new Player();
fred.setPlayerId(123); // set the primary key
query.read(fred); // finds Fred in the database by primary key
Notice that the class is Player and the table is PLAYERS. Persism understands that and maps this for you without annotations. Heck, the library will also map things like Category -> CATEGORIES and PlayerAttributes - > [Player Attributes]. Plural table names and tables with spaces in the names would all map fine without annotating anything.
Command is similar:
Command command = new Command(connection);
Player player = new Player();
player.setPlayerId(123);
player.setPlayerName("Fred");
player.setEmailAddress("x@y.com");
command.insert(player );
player.setPlayerName("Barney");
command.update(player );
command.delete(player);
I’ve been using this library myself in various production applications. I marked it beta for now because I need some feedback on it before I finalize the API and also I added support for several different databases.
Current databases supported:
MSSQL (JTDS and MSSQL driver)
Oracle
MySQL
Derby
H2
SQLite
Thanks everyone! Let me know what you think!