Skip to content

Category Archives: Hibernate

Spring Hibernate Annotation Criteria Query Example

I’ve written the start of another data load updating framework. This time I’m using Spring, Hibernate, and Hibernate Annotations. It took a little tweaking to get this to work, and so I’ve decided to add my example in the hopes that this will help others get started quickly. This is a very basic example but [...]

Coding by Conventions in Hibernate by implementing NamingStrategy, ImprovedNamingStrategy

Ever thought how you could have sensible defaults with your pojos and table column mappings, just like good buddy – Ruby on Rails? Hibernate provides an extremely simple and useful API for writing custom rules and strategies for converting column names/table names to/from your pojos/domain objects to data model. Have a look at org.hibernate.cfg.NamingStrategy Say, [...]

Generic search for auto complete using Hibernate, Ajax, Scriptaculous – Part 1

Ever wondered how to write a custom search function with pattern matching, generic enough to for an auto completer using Hibernate? In this part I will explain the back end portion of writing an auto completer, for the next part you will see an Ajax front end using DWR and scriptaculous. Use Case Scenario – [...]

Coupling Domain objects with Dao Layer using Java generics in Hibernate

More often we have domain driven design in our agile projects (with hibernate Dao and pojos as domain obejcts) and it tends out to be that we need a “base” object or a handle for both. In the past we used to write Daos which ended up doing pretty much eveything for multiple Domain Objects. [...]

Hibernate and the Composite-ID, revisited (with example solution)

Some time ago, I posted a question about Composite-IDs in Hibernate. Not surprisingly, I didn’t get much for a response. Usually, each table in the database has a primary key, some unique identifier that only belongs to a single row of data, or once mapped, a single instance of an object. I was having a [...]

Spring JDBCTemplate Example

At my latest client engagement I’ve become the king of batch applications. Small, stand-alone applications run via a scheduler or a set of shell scripts that perform a heavy amount of data-munging. The problem with being assigned batch applications is that they’re never allocated much time in the project plan; in fact sometimes they’re not [...]

Help: Hibernate Composite ID

I’m calling for help here guys! I have a database with a bunch of tables that are devoid of primary keys. When I auto-generated the xml and Java files with Hibernate Tools, I got an Id class in addition to the bean class for each mapping. But, all of the properties are stored in the [...]

Ehcache Redux

Ok, I promised I would write more about ehcache earlier this month, so here it is. Ehcache is one of several caching options for hibernate. But is the only OS one, I believe. And it’s the default caching option for Hibernate, and it’s what I’m using for the current project. This is how I configured [...]

Performance Tuning Hibernate Batch Process

I recently had to write a batch process in Java using Hibernate and Spring – a real standalone application with a main() and everything. This has been a fairly unique experience for me, since I normally work within an application; with only one logger, with a shared Spring applicationContext.xml, etc. The following outlines what I [...]