2014-04-27

Key-value Coding in Java

I would like to introduce a guide to the key-value architecture of domain objects where their attributes are provided using objects called Keys only. The Key-value approach simplifies and accelerates the development of applications. Practical use is demonstrated in the Demo-Hotels project linked at the end of the original article. The chapter list follows:
  • Writing and reading values
  • Restoring default values
  • Shallow copy of an object
  • Validation attributes when writing
  • Composite Keys
  • Criterion as a condition model
  • Criterion for filtering collection
  • Collection sorting
  • Serialization of Keys
  • Import from CSV format

Short examples are based on the Ujorm library.

key-value-model

Link to the original article:
http://ujorm.org/sample/key-value.html

2014-03-11

Ujorm version 1.44

there is available a new version Ujorm in Maven repositories with a long-awaited support for creating hierarchical queries for a database relations to itself. Previously it was necessary to use a native SQL commands, however it can be modeled using Ujorm key type by an extended alias name for relation now. The next example shows a query for all Customers with a surename "Brown" and grandparent called "Smith":

     Criterion<Customer> crn1, crn2, crn3;
     crn1 = Customer.PARENT.alias("parent1")
       .add(Customer.PARENT).alias("parent2")
       .add(Customer.SURENAME).whereEq("Smith");
     crn2 = Customer.SURENAME.whereEq("Brown");
     crn3 = crn1.and(crn2);

     Customer customer = session.createQuery(crn3).uniqueResult();

aliases can be used also in some cases where one entity contains multiple keys to the same entity, an example may be two relations Person.MOTHER, Person.FATHER.


Other features of the Ujorm series 1.4x:
  • XML configuration of an ORM meta-model can be validated using a XSD file
  • and there is available a new module (ujo-xsd) to generate XSD files accoridng an UJO class
  • ORM supports native DB sequences using the class NativeDbSequencer
  • ORM lazy loading can be enabled (optionally by a parameter) on the closed session too, for the case an action opens a new DB connection for a necessary short time only
  • there was removed the interfaces Property, which has been deprecated since version 1.30 and should be replaced by a new interface Key (including related methods)


more detailed description is in the release notes.

2013-10-01

The CRUD application for Ujorm and Wicket

The java library Ujorm was introduced in 2008 under the old name UJO Framework. Since then, five years have passed and the source code has been modified many times but the basic idea - accessing to the properties by constants called keys - remains.

I would like to present a small web project for hotel booking to show an interesting features of the Ujorm library. Graphical interface is rendered by the  Apache Wicket framework.

See the next screenshot of the form dialog including a source code:

hotelFormGui


hotelFormCode

To be continued ...

2013-01-20

Ujorm 1.32 released

The new release of Ujorm framework is released with two major features:
  • the new validators are available for checking a consistency of the input values. The Ujorm validators have got a similar meaning for Ujo object how the Bean Validation (JSR 303) implementation for the JavaBeans.  For more information see the the documentation or a jUnit tests.
  •  the ORM supports reading a related database tables by the one SQL request using an extended implementation of the Query object. More information are described in ORM user guide.
See a more information on the release notes page.

2012-12-11

Ujorm 1.31 released

There is available a new release of Ujorm framework, the major changes are:
  • database statements UPDATE or DELETE supports entity relations in the Criterion - including batch mode
  • SQL entity and column names can be "quoted" optionally in the real SQL statements, for more information see the method: MetaParams.setQuotedSqlNames()
  • the one critical bug is fixed for some cases of the lazy loading
  • explicitly defined Key name created using a factory is fixed now
  • there is available the new great plugging to NetBeans IDE to generate getters and setters easy for UJO - thanks to Martin Mahr
See a more information on the release notes page.

Getter Generator for NetBeans

I would like to introduce a new open-source plugin designed for NetBeans IDE 7.2 which is used for generating getters and setters of the UJO objects by its Keys. The source  is ready to download on the SourceForge repository code include binaries. To illustrate see a few screenshots:

1. Download a file type "nbm" from SourceForge to a local directory and call the NB-plugin manager to install the plugin:




2. The new plugin we can find in the context menu on the place, where we have actions for generate getters and setters for the ordinary JavaBeans:





3. The dialog lets as select a Keys to getters and setters. The last option below under the list enables to copy a JavaDoc from Keys to the methods.





4. Result: The generated code will look similar to the following:



For this plugin deserve our thanks to the author Martin Mahr.