This has come up again under HHH-10345.
The original request here claims that Oracle have deprecated LONG (
LONGVARCHAR) and LONG RAW (LONGVARBINARY). It refers to the 9i release
notes as "proof" of that. The 9i release notes do mention LONG
datatype being deprecated. However, it does not mention LONG RAW. The
next 2 references it links are from 10g and 11i; both of these do mention
LONG RAW specifically being deprecated. So LONG was deprecated as of 9i.
It is a bit unclear exactly when LONG RAW was deprecated.
Unfortunately Oracle has issues with both LONG and LOB forms. In fact the
list of restrictions for LONG and LONG RAW is incredibly long. As far as
I can tell newer Oracle releases have alleviated some of the crazier
"limitations" of LOB usage; but its unfortunately been many years since I
have "used Oracle in anger", so I do not really know the complete current
state of its LOB support.
While I personally agree that we should not be retroactively changing our
legacy Oracle-based dialects to map LONGVARCHAR to (N)CLOB and LONGVARBINARY
to BLOB, I do think that is something we want to change moving forward.
Specifically, I wonder if Oracle12cDialect is "foward". We knew about
these deprecations when Oracle12cDialect was developed and clearly these
types are deprecated prior to Oracle 12c even if exactly when Oracle
deprecated them is a bit murky. So specifically I wonder if, for 5.1, we
ought to make this change for Oracle12cDialect. What do y'all think?
On Mon, Oct 17, 2011 at 6:11 PM Gail Badner <gbadner(a)redhat.com> wrote:
There is a discussion about direct binding (fast) and stream binding
(slow) at . I think it answers Scott's questions. Rather than repeating
the info here, please take a look at the Oracle documentation (
After thinking about this more, I think we should keep the Oracle dialects
as is. Here are my reasons:
- Hibernate defines the text/image types consistent with how Oracle maps
- the bug lies with Oracle;
- Oracle has effectively deprecated valid SQL data types (LONGVARCHAR and
- the migration from "text" to "materialized_clob" has already been
documented since 3.5; "image" is a new type as of 3.6;
- anyone actually using text/image with LONG/LONGRAW columns may run into
new migration issues in Hibernate 4.0.0; more testing would need to be done
to determine the true impact;
- users can easily create a new dialect making the changes I mentioned
- this avoids having to make a confusing recommendation (i.e., using
Oracle11gDialect for accessing an Oracle 10g DB).
Regarding Oracle tests, IMO, the tests using "text" and "image"
disabled. If there is no similar test using clob/blob, it would be a good
idea to add one.
----- Original Message -----
> From: "Łukasz Antoniak" <lukasz.antoniak(a)gmail.com>
> To: "Strong Liu" <stliu(a)hibernate.org>
> Cc: "Scott Marlow" <smarlow(a)redhat.com>, "Gail Badner"
> Sent: Sunday, October 16, 2011 11:36:49 AM
> Subject: Re: [hibernate-dev] HHH-6726 LONG and LONG RAW column types in
> Currently Oracle supports database versions from 10.1 to 11.2 .
> and LONG RAW data types are deprecated since version 8 and 8i
> before September 2000) . Oracle keeps those column types only for
> backward compatibility .
> I tried the following scenario (Oracle 10gR2):
> 1. Create schema with "hibernate.hbm2ddl.auto" set to "create".
> column is created.
> 2. Insert some data.
> 3. Modify Oracle dialect as Gail suggested. Avoid setting
> 4. Insert some data.
> To my surprise the test actually passed :). However, I think that we
> cannot guaranty the proper behavior in every situation.
> As for performance, ImageType is extracted by calling
> ResultSet.getBytes() method, which fetches all data in one call .
> don't suppose a major performance difference when data is streamed in
> another call. oracle.jdbc.driver.LongRawAccessor.getBytes also
> data by reading the stream.
> The bug reading LONG column affects JDBC drivers since version
> I think that we have to choose between:
> - changing Oracle10gDialect. Make a not about it in migration guide
> 4.0 and update "5.2.2. Basic value types" chapter in Hibernate
> - introducing Oracle11gDialect. It can sound weird to access Oracle
> database with Oracle 11g dialect.
> - disabling execution of Hibernate tests that fail because of this
> with @SkipForDialect (and maybe develop another version of them with
> CLOBs and BLOBs, @RequiresDialect). Hibernate is written correctly
> according to "Default Mappings Between SQL Types and Java Types"
> (referenced earlier by Gail) and this is more Oracle's JDBC
> implementation issue. This option came to my mind, but it's weird :P.
> I would vote for the first option.
> Lukasz Antoniak
> (page 4)
>  "Getting a LONG RAW Data Column with getBytes"
> Strong Liu pisze:
> > I think oracle 11g is the only one supported DB version by oracle,
> > can we just introduce a new oracle dialect with suggested changes,
> > and deprecate all other existed oracle dialects? this won't
> > affects users app
> > -----------
> > Strong Liu <stliu(a)hibernate.org>
> > http://hibernate.org
> > http://github.com/stliu
> > On Oct 15, 2011, at 11:14 AM, Scott Marlow wrote:
> >> How does this impact existing applications? Would they have to
> >> convert
> >> LONGs to CLOBs (and LONGRAWs to BLOBs) to keep the application
> >> working?
> >> As far as the advantage of CLOB over TEXT, if you read every
> >> character,
> >> which one is really faster? I would expect TEXT to be a little
> >> faster,
> >> since the server side will send the characters before they are
> >> asked
> >> for. By faster, I mean from the application performance point of
> >> view. :)
> >> Could this be changed in a custom Oracle dialect? So new
> >> applications/databases could perhaps use that and existing
> >> applications
> >> might use LONGs a bit longer via the existing Oracle dialect.
> >> On 10/14/2011 09:22 PM, Gail Badner wrote:
> >>> In , I am seeing the following type mappings:
> >>> Column type: LONG -> java.sql.Types.LONGVARCHAR ->
> >>> java.lang.String
> >>> Column type: LONGRAW -> java.sql.Types.LONGVARBINARY -> byte
> >>> org.hibernate.type.TextType is consistent with the mapping for
> >>> LONG.
> >>> org.hibernate.type.ImageType is consistent with the mapping for
> >>> LONGRAW.
> >>> From this standpoint, the current settings are appropriate.
> >>> I understand there are restrictions when LONG and LONGRAW are
> >>> used and I see from your other message that there is Oracle
> >>> documentation for migrating to CLOB and BLOB.
> >>> I agree that changing column type registration as follows (for
> >>> Oracle only) should fix this:
> >>> registerColumnType( Types.VARBINARY, 2000,
> >>> registerColumnType( Types.VARBINARY, "blob" );
> >>> registerColumnType( Types.LONGVARCHAR, "clob" );
> >>> registerColumnType( Types.LONGVARBINARY, "blob" );
> >>> registerColumnType( Types.VARCHAR, 4000, "varchar2($l
> >>> registerColumnType( Types.VARCHAR, "clob" );
> >>> Steve, what do you think? Is it too late to make this change for
> >>> 4.0.0?
> >>>  Table 11-1 of Oracle® Database JDBC Developer's Guide and
> >>> Reference, 11g Release 1 (11.1)
> >>> (
> >>>  Hibernate Core Migration Guide for 3.5
> >>> (http://community.jboss.org/wiki/HibernateCoreMigrationGuide35
> >>>  Table 2-10 of Oracle® Database SQL Language Reference
> >>> 11g Release 1 (11.1)
> >>> (
> >>> ----- Original Message -----
> >>>> From: "Łukasz Antoniak"<lukasz.antoniak(a)gmail.com>
> >>>> To: hibernate-dev(a)lists.jboss.org
> >>>> Sent: Thursday, October 13, 2011 12:50:13 PM
> >>>> Subject: [hibernate-dev] HHH-6726 LONG and LONG RAW column types
> >>>> in Oracle
> >>>> Welcome Community!
> >>>> I have just subscribed to the list and wanted to discuss
> >>>> HHH-6726
> >>>> JIRA
> >>>> issue.
> >>>> Gail Badner wrote
> >>>> (
> >>>> HHH-6726 (Oracle : map TextType to clob and ImageType to blob)
> >>>> https://hibernate.onjira.com/browse/HHH-6726
> >>>> There have been a number of issues opened since the change was
> >>>> made
> >>>> to
> >>>> map TextType (LONGVARCHAR) 'long' and ImageType
> >>>> to
> >>>> 'long
> >>>> raw'. This change was already documented in the migration
> >>>> Should
> >>>> the mapping for Oracle (only) be changed back to clob and blob?
> >>>> HHH-6726 is caused by an issue in Oracle JDBC driver (version
> >>>> 10.2.0.4
> >>>> and later). This bug appears when LONG or LONG RAW columns are
> >>>> accessed
> >>>> not as first or last while processing SQL statement.
> >>>> I have discussed the topic of mapping TextType to CLOB and
> >>>> ImageType
> >>>> to
> >>>> BLOB (only in Oracle dialect) with Strong Liu. Reasons for doing
> >>>> so:
> >>>> - Oracle allows only one LONG / LONG RAW column per table. This
> >>>> might
> >>>> be
> >>>> the most important from Hibernate's perspective.
> >>>> - LONG / LONG RAW - up to 2 GB, BLOB / CLOB - up to 4 GB.
> >>>> - In PL/SQL using LOBs is more efficient (random access to
> >>>> data).
> >>>> LONG
> >>>> only sequential.
> >>>> - LONG and LONG RAW are deprecated.
> >>>> What is your opinion?
> >>>> Regards,
> >>>> Lukasz Antoniak
> >>>> _______________________________________________
> >>>> hibernate-dev mailing list
> >>>> hibernate-dev(a)lists.jboss.org
> >>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >>> _______________________________________________
> >>> hibernate-dev mailing list
> >>> hibernate-dev(a)lists.jboss.org
> >>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >> _______________________________________________
> >> hibernate-dev mailing list
> >> hibernate-dev(a)lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/hibernate-dev
hibernate-dev mailing list