3 Replies Latest reply on Apr 26, 2007 12:37 AM by christian.bauer

    Possible to Stream Object to user in Seam?

    aschneid75

      We have documents stored in our database that we want to allow users to download. In the past I have implemented this in a Servlet or Struts action and streamed the object back to the client with the appropriate headers set and then closed the connection. I have looked through the Seam book, reference guide, and searched the forums and cannot find anything similar within Seam.

      Is there a way to do this within Seam, or should I just write a Servlet to handle document requests?

      Thanks,
      Andrew

        • 1. Re: Possible to Stream Object to user in Seam?
          msduk

          I had a look arround and decided that a sevlet was the only option although I am far from an expert.

          One word of advice - when you are doing your database ensure that you have your blob in a separate table. I was unable to convince hibernate to lazy load blobs. This meant a 20 line file listing was causing memory errors all over the place.

          Also I had to use java.sql.Blob as the datatype - byte[] wouldnt play nicely although thats probably more likely a mysql database driver issue.

          • 2. Re: Possible to Stream Object to user in Seam?
            jazir1979


            I'm using a byte[] and MySQL together and it works fine, although I did have a feeling the lazy loading is being ignored as the original poster said, but haven't tested it properly.

             @Lob
             @Basic(fetch = FetchType.LAZY)
             @Column(nullable = false)
             public byte[] getData() {
             return data;
             }
            



            • 3. Re: Possible to Stream Object to user in Seam?
              christian.bauer

              You can not lazy load a byte[] (how is this supposed to work?)

              You can lazy load a byte[] if you run the bytecode instrumentation Ant task of Hibernate, after you declare FetchType.LAZY (which is a hint for the instrumentation in that case).

              You can lazy load a java.sql.*lob (that's the whole point of these types).