0 Replies Latest reply on May 5, 2008 12:06 PM by Anandu Suri

    Exception inserting BLOBs

    Anandu Suri Newbie

      Hello all,

          I don't even know if this is the right place to post this. I have been trying to insert images in a oid column of postgreSQL table. I could somehow manage to use s:fileUpload to read the content into an input stream. But whenever I try em.persist(), an exception occurs saying that Blob cannot be manipulated from creating a session.

      I googled this exception, but nothing turned up. The Hibernate site had a solution but it was for session object where they seem to open a transaction. Hibernate doc seems to be confusing in that they say the @PersistenceContext should do all transaction work when using JTA. But still the exception occurs.

      Here's my Entity

      public class TestNode implements java.io.Serializable {
          private static final long serialVersionUID = 1L;
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          long id;
          String fileName;
          Blob image;
          ///Getters and setters

      And here is my seam code

          public String upload() {
              TestNode tmp \= new TestNode();
              try {
              catch (Exception e) {
              return "/test.seam";

      This class is annotated as @Stateful and @Name("TestUpload")

      Am I doing something wrong? How to open a new transaction as it is opened in Hibernate?