Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Need suggestion on Hibernate+Oracle

RE: Need suggestion on Hibernate+Oracle

From: Ellis R. Miller <>
Date: Sun, 13 Mar 2005 10:34:03 -0600
Message-Id: <>

Worked on 3 database agnostic/independent apps back in the .com days and none of them would scale. In one case the application leveraged TopLink or "TopStink" or "FrankenLink" as it was endearingly dubbed AT THAT TIME which was prior to the Oracle purchase so I would never call it that, now.

As already mentioned, TopLink used to generate the SQL the primary casualty being the lack of bind variables. Luckily, around this time, Oracle 8.1.6 release 2, CURSOR_SHARING=FORCE first debuted. Despite the endless discussions this could generate, yada, yada, yada, it went where no init parameter had gone before and "solved" the issue regarding the lack of support for bind variables (also, of course, couldn't use SQL hints). Later, by the way, this and more was "fixed" or enhanced by TopLink and both are currently supported...along with other optimization features I am sure I am not aware of.

TopLink is the best Object-Relational mapping tool I have worked with yet all such apps were dubious with regard to scalability (as in they wouldn't) and all of them were Java based as my OR experience pre-dates .NET. No PL/SQL stored procedures, of course, and the big one being that TopLink managed both the SQL generation and the persistence layer refresh at that time (sort of like Container Managed Persistence in EJB). Unfortunately, this often meant TopLink would refresh an entire section of the schema when a mere table was updated and this is also open to lengthy discussion but let's just say it wasn't always real timely with regard to concurrency which also meant the developers were prone to creating islands of tables to avoid that cascading refresh (yeah, that'll do her up good and proper).

With regard to the OO mapping the relational schema was designed WITHOUT consideration for the OO layer as the OR mapping tool is meant to just snap on top of the schema like Jesus is the mediator between god and man. I am fairly certain there has been no Constitutional amendment to ban such behavior so the mayor in Boston still maps his relational design to the middle tier OO layer yet there has been talk...I hear things. This, of course, is so Java developers can code against OBJECTS...creates illusion of 1-to-1 mapping of Java objects to database tables so they don't get confused. On the other hand, I have seen my Java code that was 12 objects turned into 1 by former C programmers trying to learn Java so what's that all about, Willis.

Ideally, with TopLink or any OO to relational mapping tool one has a mediator or a TopLink Priest to map the objects so 1 TopLink object logically maps to 3 Oracle tables, for example, in 3NF. There was a time where I was that TopLink Priest...then I decided to get a girlfriend and my wife got upset so...

TopLink is the best OO relational mapping tool I have seen and used. Later, they added support for Oracle bind variables and were purchased, of course, by the same. (If I could go back in a time machine I would be worth $1.50, now).

Now that Oracle has FULL OODBMS support including inheritance one could try building that futuristic J2EE database app with a OODBMS schema where Java and RDBMS now become one in holy union the way god meant it to be as opposed to that OO Relational mapping where cats lie with dogs. Go one step further and toss in Java stored procedures, again, something I have used and tested but never in production and one would really have to wonder.

I am a huge fan of JBoss and have found that app server to be amazingly lightweight and full-featured (yeah, that's what I'm talkin' 'bout). I have read about Hibernate and would have to assume, aside from TopLink, it is a good second choice although TopLink has come a long way and there is a guy named Don from Canada whose picture used to be on technet who supports TopLink. I worked with him back in the day/threatened to take his rental car money playing chess for $'s which was prior to the Oracle purchase and he is good people and could probably provide some feedback regarding TopLink versus Hibernate...I assume his picture and name and such are still out there.

The short answer is this: RDBMS schema in 3NF, for example, the OR mapping tool to reflect OO system design i.e. UML based model where an Employee is a type of person (inheritance) and has all attributes (and methods) contained in what very well could be 3 tables on the database side. So, one has there RDBMS schema designed by independent database experts and a panel of celebrity judges and one has their UML jazz (use cases, interaction diagrams, etc) where Java object world is modeled independent of database schema. After these two exercises take place, usually in double-blind-taste tests where neither group speaks to one another except to argue about the existence of demons and whether an angel can actually fall by hooking up with a bad man such as me, the Object-Relational mapping tool marries the two. If one thinks about it one would see where, in theory, a discussion as to the OO system design or UML jazz in consideration of the RDBMS schema design would actually b#$%#$ize either or both models.

Finally or maybe not as its Sunday and time to hold church down South, here, there is that concept of the Object-Relational database schema that is a hybrid (sort of like snowflake in data warehousing) where one designs their 3NF OLTP database schema, for example, then creates Oracle database objects on top of the relational schema so 1 object maps to 3 tables and that 1 object is from the UML or OO model so the Java programmers can still code against objects IN THE DATABASE and on and on and on and on. "Object-Relational DBMSs: Tracking the Next Wave" by Michael Stonebraker and Paul Brown is a fine treatise/book on the matter. I would have to wonder if this would scale. Nevertheless, it does seem like the next thing to try...I tried it back in 2000 and got yelled at for trying to play god and yet I don't believe in her.

When I spend too much time on OR these days I like to sit back and enjoy a nice refreshing Coke and bust out GTA San Andreas on the PS2 and hang with Dr. Dre and car-jack 'em Java developers. That's what I'm talkin' 'bout Mr. Drummond.

-----Original Message-----
From: [] On Behalf Of Mladen Gogala
Sent: Sunday, March 13, 2005 4:11 AM
Cc: oracle-l
Subject: Re: Need suggestion on Hibernate+Oracle

On 03/13/2005 04:50:46 AM, Christian Antognini wrote:

> The goal of a transparent persistence framework like Hibernate is that =
> the developer should design the object model independently from the =3D
> database design.

And that is a recipe for disaster. I haven't seen a single attempt of writi= ng
a "database independent application" which wasn't a pure and unadulterated = disaster.
OO structure which is not aware of gory implementation details usually beco= mes
aware of them when the clients start suffering 15-minute response times in = an=20
online application.=20
Those shrewd solutions are usually built using JDBC and dynamic SQL, with u= tter disdain
for bind variables. Special beauties are 16k long SQL statements which cont= ain clever
tricks like "rownum<2" condition to ensure uniqueness. Of course, putting u= nique constraint
in place would break the database independence, because IdiotBase+ doesn't = support unique=20
constraints, unless the database is mauve. There is only one thing I can say about so called "database neutral applica= tions":=20
I resemble that!

Mladen Gogala
Oracle DBA


Received on Sun Mar 13 2005 - 11:37:28 CST

Original text of this message