Page 1 of 1

Postgres - Large Objects may not be used in auto-commit mode

Posted: Thu Mar 22, 2012 7:11 pm
by jearles
Hello:

We are creating a REST layer on top of Broadleaf, using PostgreSQL as the database.. We have a Spring MVC Controller that calls our Service Layer, and then translates the results into DTOs (which are processed by Jackson to become JSON). Today, when attempting to read Products we hit a problem. Product currently use @Lob to map description. Despite the use of Lob the application is truncating at 256 characters. That is a issue, but not what has triggered this post. Today when doing a READ of products, I received this error:

org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.

Has anyone seen this error and figured out what is causing it, or determined a work-around? At the moment we are using the OpenEntityManagerInViewFilter to allow our DTO translation to access any lazy-loaded collections. Could this be causing the problem?

If anyone has any ideas I would appreciate hearing them.

Thanks,

- John

Re: Postgres - Large Objects may not be used in auto-commit mode

Posted: Fri Mar 23, 2012 12:08 pm
by jearles
I figured this out. The way that PostgreSQL deals with Lob fields requires a transaction, even if you are just reading. We had created a new service and did not have an aop:config entry in our Spring Application Context to configure the Transactional Advice for its methods. Once I added this the appropriate transaction context is setup and product data is returned with no error.

Re: Postgres - Large Objects may not be used in auto-commit mode

Posted: Tue Jun 12, 2012 8:23 am
by phillipuniverse
Hey James, just an FYI we've come up with an extensible strategy for REST in the framework itself. It's currently in the 1.7.0-SNAPSHOT version (represented by the develop branch in our repository) in the org.broadleafcommerce.web.api.* packages in the broadleaf-framework-web artifact. We have made headway on internal documentation which should be externally available in the next few weeks. Our approach essentially uses Jersey for content negotiation and JAX-RS for serialization. Classes start here: https://github.com/BroadleafCommerce/Br ... re/web/api