Over the summer at work, one of my projects was creating an application to print a new Bill of Lading that showed an itemized record of each package.  This involved pulling data from a legacy system and using BIRT (Business Intelligence and Reporting Tool) from the Eclipse Foundation.  I’m not a huge fan of BIRT, mainly for the fact that I’m not a fan of report writing.  But I got the short straw and had to learn it for our main project.  So using it on this project made sense.

I decided to use JPA (Java Persistence API) for my data access.  It would give me an opportunity to learn something new, get a different perspective from Hibernate, and since the other members on my team had used it I had ready tech support.

The project was a success, though making the “Holy Grail” of Bill of Ladings seems a little like overkill it was a good learning experience and was my first project that I was a major part of to make into production.  We’ve had some peculiarities caused by the legacy system that we’ve had to accommodate for.

I did have one major mistake that I rectified this week after a swift kick to the head from a team member.  I’d been letting Spring inject an EntityManager into each one of my DAOs (Data Access Objects).  I’d found a great series of articles on using JPA and setting up a generic framework for your DAOs.  But I’d neglected to realize that the articles must not have been written for the web world and threading.  EntityManager’s  aren’t thread safe.  While this wasn’t seeming to cause us a problem, it was a good idea to rectify it.

EntityManagerFactory’s are thread safe, so it was a pretty easy change to switch over to injecting the correct entity factory and then creating an EntityManager as needed for every method that required one and then closing it.  Hopefully, this will circumvent one issue that was caused by our legacy database driver.  Fingers crossed.

I really like JPA.  I used EclipseLink as the JPA provider.  Annotations rule for all this ORM (object relational mapping) stuff.  So much nicer than the load of Hibernate XML files.  I believe Shindo told me this years ago, and I’m glad I finally had an opportunity to use it.  On our main project, we’ll be stuck in Hibernate XML hell forever, most likely.  I know Hibernate has it’s own annotations for this, as well as coming JPA support, but I really like the seemingly lightweight feel that EclipseLink gives me.


Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: