Are you looking for an easy to use, quick object-relation mapping (ORM) solution with a small footprint? Try the Ujorm.

 

architecture

Why a new ORM mapping?

Simplified Class Model of The Ujorm
  • framework has a type safe query language which allows the java compiler find a syntax error similar like a 4GL database language
  • never more a LazyInitialization exception though a lazy initialization is supported
  • no confusing proxy business objects
  • no list properties are supported but a special object called UjoIterator is designed for a collection. The UjoIterator provides a toList() method for example
  • easy to configure the ORM model by java source code, optionally by annotations and a XML file
  • great performance, some types of SELECT query are very fast in comparison to its competitors
  • small size of JAR file and no more library dependencies

architecture

Some other features

  • resources for ORM mapping can be a database table, view or native SQL SELECT
  • JDBC query parameters are passed by a question notation to the PreparedStatement for a high security
  • all persistent objects are based on the interface OrmUjo, namely on the implementation OrmTable
  • internal object cache is based on the WeakHashMap class so that large transactions does not cause any OutOfMemoryException
  • the API was inspired mainly by Canyenne and Hibernate frameworks. I would like to thank the authors for good work.

architecture

Sample of usage:

See how to create database and to how to INSERT an order with two items into database:
  OrmHandler.getInstance().loadDatabase(Database.class);

  Order order = new Order();
  order.setDate(new Date());
  order.setDescr("John's order");

  Item item1 = new Item();
  item1.setOrder(order);
  item1.setDescr("Yellow table");

  Item item2 = new Item();
  item2.setOrder(order);
  item2.setDescr("Green window");

  Session session = OrmHandler.getInstance().getSession();
  session.save(order);
  session.save(item1);
  session.save(item2);

  session.commit();
The next source code calls a SELECT by the UJO Criterion:

  Criterion<Order> cn1, cn2, criterion;

  cn1 = Criterion.newInstance(Order.DESCR, "John's order"); // equals to
  cn2 = Criterion.newInstance(Order.DATE, Operator.LE, new Date());
  criterion = cn1.and(cn2);

  Session session = OrmHandler.getInstance().getSession();
  UjoIterator<Order> orders = session.createQuery(criterion).iterate();
  System.out.println("ORDER COUNT: " + orders.count()); // method calls SQL SELECT COUNT(*) in case the iterator can provide first item!

  for (Order order : orders) {
      String descr = order.getDescr();
      System.out.println("ORDER ROW: " + order + " // descr: " + descr);
  }
And how to get meta-data for a 'description' property of the Order?
  OrmHandler hr = OrmHandler.getInstance();

  MetaColumn c = (MetaColumn)
             hr.findColumnModel(Order.DESCR);

  StringBuilder msg = new StringBuilder()
      .append("\n Length : " + c.getMaxLength())
      .append("\n NotNull: " + c.isMandatory())
      .append("\n PrimKey: " + c.isPrimaryKey())
      .append("\n DB name: " + c.getFullName())
      ;

  System.out.println(msg);
  

support

Support: