3 Replies Latest reply on Sep 18, 2007 7:37 PM by goku2

    Attach Entity

    mcsous

      Hello,

      I'm wanting to save attach file in DataBase. I used this annotation:

      @Basic(fetch=FetchType.LAZY)
      @Column(updatable=false)
      private byte[] content;


      This works fine, except one thing, the fetch strategy doesn't work. The attach content always select like EAGER fetch strategy.

      How can I lazy the content?

      Thanks,

        • 1. Re: Attach Entity
          goku2

          Add the @Lob annotation

          @Basic(fetch=FetchType.LAZY)
          @Column(updatable=false)
          @Lob
          private byte[] content;
          




          • 2. Re: Attach Entity
            mcsous

            Ok, but if I add @Lob annotation in, Postgres Database, the column type will be wrong and won't save any file. The type column is oid and could be bytea.

            • 3. Re: Attach Entity
              goku2

              mcsous, if you specify

              @Basic(fetch=FetchType.LAZY)
              @Column(updatable=false)
              @Lob
              private byte[] content;
              


              In postgres (al least 8.2) it will map to a Oid column, not a blob.
              Cheers