OpenJPA
  1. OpenJPA
  2. OPENJPA-740

In MySQL use LONGBLOB, MEDIUMBLOB etc.. when needed, cause BLOB only holds 64kb of data.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.2.0, 1.2.1, 1.2.2, 1.3.0, 2.0.0-M3, 2.0.0-beta, 2.0.0-beta2
    • Fix Version/s: 1.3.0, 2.0.0-beta3
    • Component/s: sql
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      When a column is annotated as a BLOB of using @Persistent to use streaming blobs, and the underlying database is MySQL, OpenJPA will create a column of type BLOB. Unfortunately, in MySQL a BLOB column can hold a (vary) limited amount of data, while (especially when using streaming blobs) the user would probably expect it to hold a large amount of data.

      Also adding the @Column annotation and specifying a size bigger than what a BLOB column in MySQL can hold, OpenJPA still creates only a BLOB column.

      I think OpenJPA should be able to create the proper column type depending on the @Column annotation if present, or otherwise default at least to a MEDIUMBLOB to preserve cross-database compatibility as expected.

      The simplest patch i can think of is setting blobTypeName="MEDIUMBLOB" in the MySQLDictionary constructor.

      Otherwise, overriding the getTypeName to properly parse the length and return the correct BLOB/TEXT type for mysql.

      1. OPENJPA-740-13x.patch
        2 kB
        Donald Woods
      2. OPENJPA-740-mysqlblob.patch
        1 kB
        Simone Gianni
      3. OPENJPA-740-trunk.patch
        2 kB
        Donald Woods

        Issue Links

          Activity

          Hide
          Donald Woods added a comment -

          Thanks Milosz, I just added a check for size==0 so it'll use the old blob size (64KB).
          For those cases, users should use your prior comment of overriding the blobTypeName.

          Show
          Donald Woods added a comment - Thanks Milosz, I just added a check for size==0 so it'll use the old blob size (64KB). For those cases, users should use your prior comment of overriding the blobTypeName.
          Hide
          Milosz Tylenda added a comment -

          Donald, just wondering about the patch - will the column type be correct (i.e. equals the type specified in blobTypeName public variable) when the size of the column is not specified?

          Show
          Milosz Tylenda added a comment - Donald, just wondering about the patch - will the column type be correct (i.e. equals the type specified in blobTypeName public variable) when the size of the column is not specified?
          Hide
          Milosz Tylenda added a comment -

          For those not able to use OpenJPA versions with fix - If only MySQL is being used or separate configurations are used for different databases (i.e. DBDictionary auto-detection is not used), setting the following property in persistence.xml should be a workaround:

          <property name="openjpa.jdbc.DBDictionary" value="blobTypeName=LONGBLOB"/>

          Show
          Milosz Tylenda added a comment - For those not able to use OpenJPA versions with fix - If only MySQL is being used or separate configurations are used for different databases (i.e. DBDictionary auto-detection is not used), setting the following property in persistence.xml should be a workaround: <property name="openjpa.jdbc.DBDictionary" value="blobTypeName=LONGBLOB"/>
          Hide
          Donald Woods added a comment -

          Fixed order for col.size() checks to correctly return the type....

          Show
          Donald Woods added a comment - Fixed order for col.size() checks to correctly return the type....
          Hide
          Donald Woods added a comment -

          Updated 1.3.x and trunk patches to match the latest svn revisions.

          Show
          Donald Woods added a comment - Updated 1.3.x and trunk patches to match the latest svn revisions.
          Hide
          Norman Maurer added a comment -

          Our bugreport listed here is related to it:

          https://issues.apache.org/jira/browse/IMAP-114

          Show
          Norman Maurer added a comment - Our bugreport listed here is related to it: https://issues.apache.org/jira/browse/IMAP-114
          Hide
          Norman Maurer added a comment -

          The Problem still exists in 1.2.2. And for me its really a blocker !

          Show
          Norman Maurer added a comment - The Problem still exists in 1.2.2. And for me its really a blocker !
          Hide
          Simone Gianni added a comment -

          This patchs uses the right column table for mysql based on the size specified for the column. I had this patch for a few months now, but no one told me how to test it in junit, so unfortunately I haven't provided a junit test case for it.

          Sice this patch is old, I don't know if it still applies to recent OpenJPA versions. If I have time to, I'll do a fresh checkout and test it.

          Show
          Simone Gianni added a comment - This patchs uses the right column table for mysql based on the size specified for the column. I had this patch for a few months now, but no one told me how to test it in junit, so unfortunately I haven't provided a junit test case for it. Sice this patch is old, I don't know if it still applies to recent OpenJPA versions. If I have time to, I'll do a fresh checkout and test it.

            People

            • Assignee:
              Donald Woods
              Reporter:
              Simone Gianni
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development