SQL Zone is brought to you in partnership with:

I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

Automating the Transaction Logic Layer for Hibernate / JPA Applications

  • submit to reddit

5 rules replace 500 lines of code. That's the claim from Automated Business Logic for their transaction logic engine: an engine that aims to automate the transaction logic layer for applications that plug into Hibernate or JPA. In particular, this framework aims to address the shortcomings of Hibernate's current attribute validation. But really, can we 500 lines of code be replaced?

To ensure certain rules are adhered to, you'll typically need to write logic somewhere - in a service layer, or in your DAOs. But with this engine, by using annotations on your Java (or Groovy) code, you avoid all this complex code. The suggested approach is to add your business logic in a parallel package to your Domain Objects. Annotations in these logic classes identify the methods for business logic - and the logic can be specified in the annotation, or programatically in the method code section.

There's much more to Automated Business Logic - while the constraints are a powerful feature, the engine also helps with multi-table derivations and actions. Complex cases such as allocation can be easily automated.

The pluggable architecture approach taken by the product means that the Hibernate and JPA APIs are preserved - you won't need to refactor your code to get the benefits of the transaction logic engine into your application.

Here's an overview of how it all works:

When you think about it, the approach is great. How much time do you waste writing boilerplate code? If you had the time you'd probably write a framework to get out of the mundane nature of repeating code. It's all provided for you here. There are other benefits - less boring code, means less bugs/maintainance on that code. And, most importantly, you can deliver your product faster.

Initially when I heard about this, I thought that I'd be adding yet another code generation phased into your project. Not so, as it's driven by annotations, and your own logic. If you work with JPA or Hibernate a lot, this could be the solution you've been looking for.

For a more complete overview, check out the following video:


Florent Ramiere replied on Fri, 2011/11/11 - 5:35pm

For those who want a one-liner installation you can go to https://github.com/framiere/automated-business-logic-jpa-spring.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.