Thursday, October 24, 2013

JTA connections with Springed HibernateDaoSupport and LOBs and Postgres.

I tried all sorts of things and never got this combination to work with LOB objects and Postgres. T.T

Postgres essentially requires you to use a transactional connection with large LOBs. And by transactional I mean that the application uses a container managed JTA transaction to commit to the database.

The problem with Spring and HibernateDaoSupport is that Spring acts as its own container so when it creates a transaction the real container views it as an application managed transaction, and gives it a non-transactional connection the database. So what's happening is that Spring manages the connection similar to how the container would, so effectively it is a transactional connection, but underneath the container provides a non-transactional connection. This works fine for most objects, but not with Postgres and large LOBs.

The solution would be to change out one of three technologies... either Postgres, Spring, or don't use LOBs.

Postgres might be the least intrusive to swap out, but I have no idea if MySQL has similar requirements.

No comments:

Post a Comment