Re: [hibernate-dev] HHH-6726 LONG and LONG RAW column types in Oracle
by Łukasz Antoniak
Currently Oracle supports database versions from 10.1 to 11.2 [1]. LONG
and LONG RAW data types are deprecated since version 8 and 8i (released
before September 2000) [2]. Oracle keeps those column types only for
backward compatibility [3].
I tried the following scenario (Oracle 10gR2):
1. Create schema with "hibernate.hbm2ddl.auto" set to "create". The LONG
column is created.
2. Insert some data.
3. Modify Oracle dialect as Gail suggested. Avoid setting
"hibernate.hbm2ddl.auto".
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 [4]. I
don't suppose a major performance difference when data is streamed in
another call. oracle.jdbc.driver.LongRawAccessor.getBytes also fetches
data by reading the stream.
The bug reading LONG column affects JDBC drivers since version 10.2.0.4.
I think that we have to choose between:
- changing Oracle10gDialect. Make a not about it in migration guide to
4.0 and update "5.2.2. Basic value types" chapter in Hibernate
documentation.
- introducing Oracle11gDialect. It can sound weird to access Oracle 10g
database with Oracle 11g dialect.
- disabling execution of Hibernate tests that fail because of this issue
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.
Regards,
Lukasz Antoniak
[1]
http://www.oracle.com/us/support/library/lifetime-support-technology-0691...
(page 4)
[2]
http://download.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90120/ch...
[3]
http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm
[4] "Getting a LONG RAW Data Column with getBytes"
http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/jstreams.htm
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 [1], 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, "raw($l)" );
>>> registerColumnType( Types.VARBINARY, "blob" );
>>>
>>> registerColumnType( Types.LONGVARCHAR, "clob" );
>>> registerColumnType( Types.LONGVARBINARY, "blob" );
>>>
>>> registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
>>> registerColumnType( Types.VARCHAR, "clob" );
>>>
>>> Steve, what do you think? Is it too late to make this change for 4.0.0?
>>>
>>> [1] Table 11-1 of Oracle® Database JDBC Developer's Guide and Reference, 11g Release 1 (11.1) (http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/datacc.htm#g...)
>>> [2] Hibernate Core Migration Guide for 3.5 (http://community.jboss.org/wiki/HibernateCoreMigrationGuide35)
>>> [3] Table 2-10 of Oracle® Database SQL Language Reference
>>> 11g Release 1 (11.1) (http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elemen...)
>>>
>>> ----- 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
>>>> (http://lists.jboss.org/pipermail/hibernate-dev/2011-October/007208.html):
>>>> 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 (LONGVARBINARY) to
>>>> 'long
>>>> raw'. This change was already documented in the migration notes.
>>>> 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
>
8 years, 9 months
Re: [hibernate-dev] Where are the batched fetch statements generated?
by Clemens Eisserer
Hi Guenther,
>>> Is it possible to disable prepared statement caching for batched fetching, so I end up with a single query in the < default_batch_fetch_size case only >>instead of the
>>> fixed-size batch loading hibernate does by default?
> I think the main reason for no feedback so far, is that nobody was able to understand this sentence.
> Usually 'prepared statement caching' is a synonym to 'prepared statement pooling' and is something which has to be provided by a connection-pool (or a jdbc-driver) and thus
> Hibernate does actually not implement any prepared statement cache/pooling.
> Can you please explain what you intend under 'prepared statement caching'?
> Can you also please try to better explain the second part of your sentence?
Sorry for beeing that cryptic, I will try to rephrase it:
When Hibernate does batch-fetching, it generates PreparedStatements
for certain batch sizes - for a batch_size of 50, the prepared
statements for batch-sizes will have the following sizes:
[1,2,3,4,5,6,7,8,9,10,12,25,50]. When e.g. a batch of size 13 should
be fetched, because of the fixed size of the prepared statements, 3
queries are issued for batch-fetching, although 13 <= 50. In this case
the 3 batches would be of the size 13 = 8 + 4 + 1.
In a latency bound (between db and application) environment, this
serverly hampers response time - instead of a single round-trip to do
the batched fetch, Hibernate requires 3.
(subselect can't be used in my case, because my queries are already
rather complex, and the added complexity confuses the DBs query
planner too much)
What I did in this case (only for integer PKs) is to pad up to the
next batch size with a non-existant PK.
So, for the example mentioned above, I can use the PreparedStatement
with size 25, and insert padding from 14-25, which will make the query
slightly more inefficient but avoid 2 additioan round-trips.
- Clemens
12 years
AssociationType.isEmbeddedInXML() no longer used
by Gail Badner
I see that AssociationType.isEmbeddedInXML() is no longer used anywhere.
Is this left over from EntityMode.DOM4J?
If so, should I go ahead and remove AssociationType.isEmbeddedInXML() and its implementation from metamodel branch?
Regards,
Gail
12 years
[HV] master does not compile for me
by Emmanuel Bernard
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[3,47] error: Interval is not public in org.hibernate.validator.test.constraints; cannot be accessed from outside package
[ERROR] /Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[4,47] error: Item is not public in org.hibernate.validator.test.constraints; cannot be accessed from outside package
[ERROR] /Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[43,2] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[43,22] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[44,6] error: package item does not exist
[ERROR] /Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[45,6] error: package item does not exist
[ERROR] /Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[47,26] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[47,76] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[57,2] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[57,18] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[58,2] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[58,26] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[63,26] error: cannot find symbol
[ERROR] class CustomViolationTest
/Users/manu/projects/notbackedup/git/validator/engine/src/test/java/org/hibernate/validator/test/constraints/path/CustomViolationTest.java:[92,6] error: method addNode in interface NodeBuilderDefinedContext cannot be applied to given types;
[INFO] 14 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Hibernate Validator Aggregator .................... SUCCESS [0.313s]
[INFO] Hibernate Validator Engine ........................ FAILURE [15.429s]
[INFO] Hibernate Validator TCK Runner .................... SKIPPED
[INFO] Hibernate Validator Integration Tests ............. SKIPPED
[INFO] Hibernate Validator Annotation Processor .......... SKIPPED
[INFO] Hibernate Validator Quickstart .................... SKIPPED
[INFO] Hibernate Validator Performance Tests ............. SKIPPED
[INFO] Hibernate Validator Manual ........................ SKIPPED
[INFO] Hibernate Validator Distribution .................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.085s
[INFO] Finished at: Wed Oct 31 16:49:07 CET 2012
[INFO] Final Memory: 30M/293M
12 years
Hibernate ORM 4.1.8 release tomorrow?
by Brett Meyer
All, I'm planning on cutting ORM 4.1.8 tomorrow afternoon. If there are any objections or reasons to delay, please let me know ASAP. Thanks!
Brett Meyer
brmeyer(a)redhat.com
12 years
New feature: Configuring “hibernate.hbm2ddl.auto” at entity level?
by Julien Martin
Hello,
I currently use the hibernate.hbm2ddl.auto property with a value of create.
While this setting is very convenient for some entities, I also have an
entity that is not going to change (i.e. reference data such as postcodes)
and that contains some data that I would like to keep across restarts of
the app server (i.e. Tomcat).
I am seeking for a way to tell hibernate/JPA not to touch this entity/table
whatever the value of thehibernate.hbm2ddl.auto property.
Is it possible to configure the value of this property at the level of an
entity and therefore override the overall behavior for a specific entity?
This would be a wonderful feature for entities that represent reference
tables/data.
Please let me know if you are planning on implementing such a feature in
upcoming versions of Hiberrnate/EntityManager.
Regards,
Julien.
12 years, 1 month
HSEARCH-1225
by Sanne Grinovero
The issue HSEARCH-1225 is about clarifying what is supposed to happen
when an entity type is having an EntityIndexingInterceptor registered
and the following method is called:
org.hibernate.search.FullTextSession.index(T)
Today, this method is ignoring the conditional indexing interceptor
altogether; this might be considered correct, but we should clarify it
as it brought some confusion.
As a reference this is the EntityIndexingInterceptor interface source code:
public interface EntityIndexingInterceptor<T> {
IndexingOverride onAdd(T entity);
IndexingOverride onUpdate(T entity);
IndexingOverride onDelete(T entity);
IndexingOverride onCollectionUpdate(T entity);
//FIXME should we add onPurge and onIndex?
}
My first idea about this was to clarify in documentation & javadoc
that the index() is going to ignore the interceptor. I thought that
would be a good idea so that users can have a method to override any
framework decision and force the write to be applied.
On the other hand, adding the methods mentioned in the FIXME would be
straight forward too, and while I'd expect most people to implement
onIndex() as return APPLY_DEFAULT, this might be a more elegant way
to:
- let the user choose about this
- make it very explicit what is going to happen
This looks like the best way to go, unfortunately it breaks backwards
compatibility but it was clearly marked as experimental in all media.
Thoughts?
#purgeAll
Of course the #purge method needs to be addressed in some consistent
way, but we can't implement it easily (and very slowly) on purgeAll.
One could redesign the MassIndexer pattern to be reused by a
mass-purger but I don't think it's worth it.
Cheers,
Sanne
12 years, 1 month