/BabyORM

A baby ORM that provides basic ORM functionality without all the fluff

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

BabyORM

A minimal ORM for accomplishing database tasks.

How the F*** do I use this thing?

Required to work
  1. The Entity/DTO type MUST have at least one field annotated with @PK. This does not mean that the field needs to correlate to an actual primary key constraint in the database.
  2. Get a new Repo via BabyRepo.forType(Foo.class));
  3. Set a connection supplier (i.e. ConnectionPoolX::getConnection)
Fancy bits

If the names of your classes and fields do not match exactly to the names of the tables and columns in the database, you will need to provide the appropriate name annotation.

If the column names only differ in casing (I.e camelCase to snake_case), you can put a @ColumnCasing annotation on the entity class to specify which case the database column names are in. This makes it so you don't have to put the @ColumnName annotation on every damn field.

If you have weird names for things: See @ColumnName, @TableName, @SchemaName.

If your primary key is not auto generated by the database, you must set a KeyProvider that returns a new key.

About

This ORM is meant to provide super light weight ORM functionality without any dependencies. It provides full CRUD capabilities for any entity object. The plan is to add only the most commonly needed features to keep usage simple.

Key features:
- Easy to learn and use
- Automagically map object fields to row columns and vice versa
- Insert, Update, Delete records
- Query by any set of columns, either ANDed or ORed together
- Query multiple values for the same key by using any kind of Collection as the value
- Arbitrary SQL query execution to fetch objects (think views in code).
- Automatically convert column names to the given Case (for instance, camelCase to snake_case)
- Support for multi column keys
- Prevent SQL injection attacks using the ORM methods. This does not apply to queries run using the execute method.
planned features:
- Support storing regular object types as JSON
- Support Joins to other tables joined by multiple arbitrary keys
- Support Transactions
- Support Lazy fetching joined entities

Why build another ORM?

It was an accident