iBatis O/R mapping

2 min read >

iBatis O/R mapping

Engineering Insights & Enterprise solutions

After some years of Hibernate or Spring+Hibernate, it was time to try something new. Not for the sake of trying something new, but more out of the need.

The problem

Think of a legacy database, very generic, without a clear business model representation. As a metadata storage database, different business objects persisted in the same data structures.

The solution

Navigating large database relationships is easily done with Ibatis. The ability to use SQL directly and then map results to objects makes it the right choice for speedy development. Once the results maps are defined, they can be reused in loadings more complex relations like 1-1 or 1-many. For 1-many, everything is done at the SQL level, with the specification of a “grouping” parameter, the one that identifies the “1” part.

Mappings separation is done using namespaces, this allows access to definitions in other SQL maps and good separation for larger applications.

Spring SqlMapClientDaoSupport provides simple methods to insert, update, and delete but also allows complex querying using various callbacks such as RowHandler or SqlMapClientCallback. A nice touch is the “queryForMap” method, which allows to easily load lookup caches or generally has results as Maps.


IBatis is surely the O/R mapping tool to use when the database is legacy and using Hibernate to map objects is not straightforward.

Unlock innovation and digital transformation for your business.

Get in touch

We are always happy to talk






165 Splaiul Unirii, Timpuri Noi Square,
TN Office 2 building, 4th floor,
District 3, Bucharest, Romania, 030134