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, 10 months
Error: registry contains more than one (2) entity manager factories: PERSISTENCE_UNIT_NAME
by Teresa Batista Neto
Dear all,
After upgrading JPA from 3.6.1 to 4.1.8 I start getting the following error:
"Error: registry contains more than one (2) entity manager factories:
PERSISTENCE_UNIT_NAME"
Below you can find a brief summary of our specification requirements.
- User logins in the web application using their own oracle database
account.
- The web application only needs to access one database schema;
- The access rights are managed using oracle roles and grant privilegies.
- Only one database schema and multiple user oracle accounts.
- We only set the username and password when users tries to login in the
web application.
- The EntityManagerFactory is created using the username and password of
the user.
- Because our web application only access one database we only use one
persistence unit name.
E.g. persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="PERSISTENCE_UNIT_NAME">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.
OracleDriver">
<property name="hibernate.connection.url" value="jdbc:oracle:xx...">
<property name="hibernate.dialect" value="org.hibernate.dialect.
Oracle10gDialect">
<property name="hibernate.default_schema" value="SCHEMA_NAME">
<property name="hibernate.connection.username" value="USERNAME">
<property name="hibernate.connection.password" value="PASSWORD">
<property name="hibernate.connection.autocommit" value="false">
<property name="hbm2ddl.auto" value="validate">
<property name="hibernate.show_sql" value="true">
<property name="hibernate.format_sql" value="true">
</properties>
</persistence-unit>
</persistence>
E.g. how we create and close the entity manager factory
Map<String, String> configuration = new ProviderConfiguration();
configuration.put("hibernate.connection.username", username);
configuration.put("hibernate.connection.password", password);
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("PERSISTENCE_UNIT_NAME",
configuration);
EntityManager em = emf.createEntityManager();
SptrTaxNode t = em.find(SptrTaxNode.class, 9606);
em.close();
emf.close();
Does anyone ever had a similar situation? Any ideas on how can I solve this
problem?
Thanks in advance,
Teresa
11 years, 10 months
[#HHH-4688] Make sure @OrderBy works for @ElementCollection - Hibernate JIRA
by Strong Liu
org.hibernate.test.annotations.collectionelement.OrderByTest was introduced by this JIRA, and it passes on master.
The question is, org.hibernate.test.annotations.collectionelement.Products#widgets, used in this test, which has @ElementCollection on it and its element type is an @Entity
but according to the JPA SPEC
{quote}
@ElementCollection
Defines a collection of instances of a basic type or embeddable class.
{quote}
so, is this a hibernate specific feature or we should "correct" this test?
-------------------------
Best Regards,
Strong Liu <stliu at hibernate.org>
http://about.me/stliu/bio
11 years, 10 months
Re: [hibernate-dev] hibernate/gradle help
by Strong Liu
I don't use eclipse, so no clue how to do that, forward this to the dev list, then others who using eclipse may help
On Dec 21, 2012, at 6:28 AM, "Repshas, David" <David.Repshas(a)Teradata.com> wrote:
>
> Strong,
> I've downloaded the latest version of Hibernate to test with our Teradata JDBC driver. Could you give me some pointers on how you do your testing with gradle ??
>
> I'm using Eclipse Juno on Windows. I ran gradle with an "eclipse" argument to generate an eclipse project file which I then imported into Eclipse.
>
> I have been able to add the Teradata information to hibernate-orm/databases and then after a rebuild, I use:
> .\gradlew --info hibernate-core:matrix_teradata
>
> to run the hibernate-core tests.
>
> I'd like to be able to set breakpoints in your Hibernate test cases. I've tried various plugins, but still don't see an obvious way to do this. The project file gradle creates lacks any reference to source directories which seems strange.
>
> Anyway, I figure since you're working on these on a daily basis, you know the answers to these questions or you can point me to some useful documentation.
>
> Thanks for your help. Hope you have Happy Holidays.
>
> Dave Repshas
>
-------------------------
Best Regards,
Strong Liu <stliu at hibernate.org>
http://about.me/stliu/bio
11 years, 11 months
Problem closing oracle session with hibernate 4.1.8
by Teresa Batista Neto
Dear all,
I'm using hibernate and oracle 11g2 in one of my projects. I had to upgrade
recently to a new version of hibernate, first from 3.6.1 to 3.6.10 and then
to 4.1.8. However after migrating to 4.1.8 now my oracle sessions are never
closed even after I close SessionFactory and I don't understand why.
Below you can find an example of how I'm creating and closing the session
factory:
- Using hibernate 3.6.10:
SessionFactory sessionFactory = new Configuration().configure().
buildSessionFactory();
Session session = sessionFactory.openSession();
Journal t = (Journal) session.get(Journal.class, 12);
session.close();
sessionFactory.close();
- Using hibernate 4.1.8:
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().
applySettings(configuration.getProperties()).
buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(
serviceRegistry);
Session session = sessionFactory.openSession();
Journal t = (Journal) session.get(Journal.class, 12);
session.close();
sessionFactory.close();
- The hibernate.cfg.xml is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</
property>
<property name="hibernate.dialect">org.hibernate.dialect.
Oracle10gDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.
OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@....</
property>
<property name="hibernate.default_schema">xx</property>
<property name="hibernate.connection.username">yy</property>
<property name="hibernate.connection.password">zz</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<mapping resource="Journal.hbm.xml" />
</session-factory>
</hibernate-configuration>
After the upgrade to 4.1.8 all oracle sessions are never closed... I
usually run the following select statement to check which are the open
connections:
select status, logon_time, SID, Serial#, UserName, SchemaName, Program,
Machine from v$session;
Please can anyone give me any insight on how to fix this?
Many thanks in advance.
Teresa
11 years, 11 months
Regression in AS7 (master) cluster cache invalidation test after moving from Hibernate ORM 4.1.6 to 4.1.9
by Scott Marlow
http://hudson.jboss.org/hudson/job/as7-param-pull/5123/ shows a failure
with the second level cache not being invalidated as expected across a
two node cluster.
I'm able to reproduce locally, which is good. We will continue to use
Hibernate 4.1.6 until we get past this regression (hopefully we can
understand the test failure cause soon).
https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/clu...
is the line that is failing (yeah, the arguments to assertEquals are
backwards but that isn't the root issue ;)
It is possible that its a bug in the test also.
The cluster has two nodes, each with their own in-memory database. The
test assumes that it can create the same entity on both nodes (same
primary key) and that for the purpose of testing the second level cache,
we can expect cache invalidation to occur on both nodes when deleting
the entity on one of the nodes.
I believe that the cache invalidation should be synchronous but I'll
probably try adding a sleep to see if it could be an async/timing issue.
I hope to have more information soon (probably in the morning on Friday).
Scott
11 years, 11 months
Re: [hibernate-dev] Problem with setting boolean parameter
by Oto Júnior
Yes Eric, this is a project/implementation detail.
I wrote here just for a "extra-information" of my problem. But you're right.
Thanks.
_______________________________________________________
Oto Soares Coelho Júnior
otojunior(a)gmail.com / otojr(a)dcc.ufmg.br
Departamento de Ciência da Computação - UFMG
2012/12/17 Eric Dalquist <eric.dalquist(a)doit.wisc.edu>:
> Also isn't the 1/0 for boolean storage a DB specific implementation
> detail? For example if running hibernate against HSQLDB you get true
> boolean columns.
>
> -Eric
>
>
> On 12/17/2012 09:22 AM, Steve Ebersole wrote:
>> No, that is no longer possible. You have a boolean, you should set a
>> boolean.
>>
>> On 12/17/2012 09:12 AM, Oto Júnior wrote:
>>> Correct.
>>>
>>> In Hibernate 2, this example with 'q.setParameter( "isActive", 1 );' works !
>>> In Hibernate 4 doesn't work.
>>>
>>> Is there any way to make work in Hibernate 4 without modify the
>>> implementation of my method?
>>> (i.e. I want to use 'q.setParameter( "isActive", 1 );' )
>>>
>>> Observation: In the database the 'true' values are stored with number
>>> 1 and 'false' values are stored with number 0.
>>>
>>>
>>> _______________________________________________________
>>> Oto Soares Coelho Júnior
>>> otojunior(a)gmail.com / otojr(a)dcc.ufmg.br
>>> Departamento de Ciência da Computação - UFMG
>>>
>>>
>>> 2012/12/17 Steve Ebersole <steve(a)hibernate.org>:
>>>> Just to make sure I understand...
>>>>
>>>> You have a domain attribute that is boolean, but you want to treat it as a
>>>> number?
>>>>
>>>> I.e.:
>>>> @Entity class Listing {
>>>> ...
>>>> boolean active;
>>>> }
>>>>
>>>> Query q = session.createQuery( "from Listing l where listing.active =
>>>> :isActive" );
>>>> q.setParameter( "isActive", 1 );
>>>>
>>>> rather than:
>>>> q.setParameter( "isActive", true );
>>>>
>>>> ?
>>>>
>>>> On 12/17/2012 07:34 AM, Oto Júnior wrote:
>>>>> Hi,
>>>>>
>>>>> I used Hibernate 2 in my software and now I'm using Hibernate 4.
>>>>> Before the version migration, the method Query.setParameter(p, 1) -
>>>>> [Integer values in boolean properties] - works well for setting
>>>>> boolean properties.
>>>>>
>>>>> Now, in Hibernate 4, doesn't work anymore.
>>>>> Anyone could help me?
>>>>>
>>>>>
>>>>> _______________________________________________________
>>>>> Oto Soares Coelho Júnior
>>>>> otojunior(a)gmail.com / otojr(a)dcc.ufmg.br
>>>>> Departamento de Ciência da Computação - UFMG
>>>>>
>>>>> _______________________________________________
>>>>> 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
>
>
11 years, 11 months
Problem with setting boolean parameter
by Oto Júnior
Hi,
I used Hibernate 2 in my software and now I'm using Hibernate 4.
Before the version migration, the method Query.setParameter(p, 1) -
[Integer values in boolean properties] - works well for setting
boolean properties.
Now, in Hibernate 4, doesn't work anymore.
Anyone could help me?
_______________________________________________________
Oto Soares Coelho Júnior
otojunior(a)gmail.com / otojr(a)dcc.ufmg.br
Departamento de Ciência da Computação - UFMG
11 years, 11 months