• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why do we need a framework other than JDBC to access DB?

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One architect from a famous IT company said that they had over 500 hundred tables in their DB and an OR mapping framework would help them to maintain the
code better and make their life easier compared to use straight JDBC.

One guy said that JDBC is too hard for average developers to do it well and EJBQL and HQL are easier and framework developers are much better than average Java developers even though you have to learn how to map and configure them.

Another guy told me that JPA and Hibernate offer too much to an average developer. iBATIS is much simpler although you still need to know JDBC.

If you were a saleswoman or salesman for one of the frameworks, what would be your sale point for JPA, Hibernate, JDO, TopLink, iBATIS, ...?
[ April 11, 2008: Message edited by: Elizabeth King ]
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was hoping Paul or Mark to answer this question.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would call bullshit on several on the points you have been told. While one could debate at length about the advantages and drawbacks of certain frameworks, in reality there isn't one that is perfect for all situations.

I'm currently in the Hibernate camp, and I like that I can deal with Java objects instead of individual attributes, like you'd be doing with straight JDBC. It's also easy to use raw JDBC alongside hibernated objects if one needs to (e.g. for batch data imports - that's an area where the ORM performance overhead gets in the way).
Modeling foreign key relationships on the basis of Java methods (i.e., calling "getParent" on an object, instead of having to call "getParentID" and then having to access the Parent table with that ID) also simplifies things.
This is all typical ORM functionality, though, not Hibernate-specific.

In general I'd advise to use ORM over straight JDBC, since it simplifies many things (and it certainly doesn't "offer too much" - you can just ignore features that aren't needed, or which you haven't your head wrapped around yet). Try one or two to see which feels natural to you, if you're otherwise unconstrained in your choice.

By the way, I think JDO does not have much of a future, now that JPA is here.
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:

...
Modeling foreign key relationships on the basis of Java methods (i.e., calling "getParent" on an object, instead of having to call "getParentID" and then having to access the Parent table with that ID) also simplifies things.
...



It is a simple inner join in one SQL statement. I'm an average Java developer and do not find any difficulties here.

Can anyone post other examples that show the advantages of any frameworks over straight JDBC?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason why I didn't respond, is that this is a long question to answer, and I just haven't had the time in the past few days.

I have posted a number of times my answer to this, which you can search in this forum.

FOr me it is one big thing, maintenance. In JDBC it is s nightmare to me, so much more code to maintain. ORM simplifies, and with cache I can make some things faster through Hibernate than JDBC. If I were to go to an interview and they said they used just JDBC, I would run far far away. My personal opinions.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a really small database and just need simple queries, I might recommend iBatis, but I probably would still recommend Hibernate because that is what I know the best, and I also work for JBoss.

Mark
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:
...
FOr me it is one big thing, maintenance. In JDBC it is s nightmare to me, so much more code to maintain. ...
Mark



Is maintaining xml files a nightmare?

So iBATIS would not offer much advantages on maintenance because it uses JDBC queries in the xml files (ObjectSQL mapping files).
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:
One architect from a famous IT company said that they had over 500 hundred tables in their DB and an OR mapping framework would help them to maintain the
code better and make their life easier compared to use straight JDBC.
[ April 11, 2008: Message edited by: Elizabeth King ]



He is right.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A framework forces developers to follow certain implementation rules. A good framework enforces good rules while a bad one enforces bad rules.
When a developer uses framework, his/her code can be understood
by other developers more easily as long as they know the framework.

When a developer uses straight JDBC, the code could be very mess or hard for others to understand although the performance may be better.

I think Hibernate and iBATIS are good frameworks. EJB (2.x) entity bean is OK, but unnecessarily complex.

I do not know why TopLink and JDO are not popular now.
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simplicity!
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:


Is maintaining xml files a nightmare?

So iBATIS would not offer much advantages on maintenance because it uses JDBC queries in the xml files (ObjectSQL mapping files).



I use Annotations.

But still, I'd much rather see xml mapping files, then JDBC code.

Mark
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>> I do not know why TopLink and JDO are not popular now.

Sorry but I can't let this remark go without a response.

While I agree that JDO is no longer popular as it has been replaced with JPA, TopLink is still a very popular product.

Although this forum tends to mainly be on Hibernate, (mainly because users get better answers here than in the Hibernate forums), the are several other very popular TopLink family (TopLink, TopLink Essentials, EclipseLink) forums.

http://forums.oracle.com/forums/forum.jspa?forumID=48&start=0

http://www.nabble.com/EclipseLink-f26430.html

http://www.nabble.com/java.net---glassfish-persistence-f13455.html

http://forum.java.sun.com/forum.jspa?forumID=13

http://www.nabble.com/JPA-General-f27110.html
 
Glen Cai
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Sutherland:
... TopLink is still a very popular product.
...



Is TopLink free now?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The complete source code from TopLink was contributed to the Eclipse EclipseLink project, which is free and open source. So, yes if you use EclipseLink, it is licensed under EPL.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks James.

While I work for JBoss and use Hibernate, I always try to mention TopLink together with Hibernate in posts asking about what Frameworks are available.

Mark
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:


I use Annotations.
...



Is maintaining Java annotation a nightmare?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:


Is maintaining Java annotation a nightmare?



Not at all.

Mark
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:


Not at all.

Mark



Are you running in a circle?

You do not like straight JDBC Java code because it is mess.

So you have the ORM framework (Hibernate) to organize
the mapping and query logic better, clearer, and cleaner
using XML & HQL or SQL.

Now you say you like to use Java annotation (because it is new in Java5?)
to configure Hibernate. The annotation mapping is not as clear as xml mapping and you still need to maintain Java code with HQL or SQL in the annotations.

Software engineering is really art now. Anyone can be an inventor. Have anyone seen an new type of violin which has only three strings. Would it be easier to play? lol...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:


Are you running in a circle?

You do not like straight JDBC Java code because it is mess.



Not even close. mapping is just mapping, xml or Annotations, I just stated that I prefer Annotations for mapping. If I was using Java 1.4 then I would be just as happy with the xml mapping files, a million times over JDBC.

In JDBC every query that you run you have to go through the ResultSet and have an adapter than will convert those result sets into Java Objects. It is a mess.

A JDBC application will have 5 to tens times more "query" database code that Hibernate. I have seen it over and over.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't want to listen to my experience of over 17 years developing Database applications with Acius 4th Dimension, Foxpro, Access, Oracle in languages such as XBase, PL/SQL, Oracle Forms and Reports, VB, Visual Foxpro and Java. Then don't believe me, it is ok to have a different opinion.

Before I ever used Hibernate, I even built a basic framework like it in VB and Visual Foxpro, because even there with ODBC or direct database access(in Foxpro's case) you had the same problem.

Mark
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like all the Set in Java collection, ResultSet is a little bit mess. I also feel that it is cumbersome to retrieve data from ResultSet, but it is a straight programming and is certainly not very difficult for most Java developers.

Introducing new frameworks on top of JDBC presents a much bigger challenge to the Java community because of the new architectures, new APIs, new configuration, new tricks, and new bugs. Although some of the frameworks look elegant, most of them do not have real new substances. The new frameworks disturb the developers� focus on the enterprises� business needs and increase the cost of development and maintenance because of lack of developers who know all the frameworks.

Java is losing the war to the MS partly because of the various open source frameworks. Sun is falling and powerless to stop something similar to Visual J++ anymore.

I know you may not agree with me.
[ April 19, 2008: Message edited by: Elizabeth King ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's true that it's not difficult to write JDBC code in Java. It's just tedious. A couple of years ago I wrote a new web application that used half a dozen database tables. Nothing complicated at all. I could have written the JDBC code to deal with those tables, but I read about Hibernate and decided to try it. And I found it was far, far easier to just set up a few configuration files. The code I had to write was shorter and simpler. Not to mention that it just worked.

So I disagree with your technical remarks. It's true that it took me a couple of weeks to learn the basics of Hibernate, but once that was done it didn't interfere with my focus on business needs. I can't imagine why doing something the easy way would prevent me from focusing on business needs. And I don't need to know all the frameworks, I just need to know Hibernate.

As for your political remarks, I don't have the background to comment on them. But I've seen such remarks made repeatedly over the last 5 years or so and they have mostly come to nothing.
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
...
And I found it was far, far easier to just set up a few configuration files. The code I had to write was shorter and simpler.

...
I don't need to know all the frameworks, I just need to know Hibernate.
...



Your code is shorter because the logic is in the configuration xml files.

One day you may say iBATIS requires easier, smaller, and simpler Java code, but don't forget the configuration. It goes on and on ...
[ April 19, 2008: Message edited by: Elizabeth King ]
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well just for FYI i am in Hibernate Camp. But JDBC 4 has made some improvements that are decent to look at.

JSR 221 JDBC 4
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:
Your code is shorter because the logic is in the configuration xml files.

In the configuration files and the Hibernate code, yes. I consider that a good thing, even if from time to time I find myself slightly irritated that I'm spending a considerable fraction of my time configuring things.
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,

I don't agree with Configuration XML files used "extensively" by frameworks to do their stuff. It makes the code decentralized and to think that a change in somewhere else (other than my code) code make things work differently gives me shrugs, that being said, I hate Annotations totally. They make my code stuffed with additional blah blah that i don't need at all. There has to be a solution in built within the language. Don't get me wrong, i am not against XML usage, but if my code depends on XML configuration I would like to see some kind of compile time error displaying mechanism as opposed to crappy runtime exceptions. I am just saying that there has to be a limit to all the configuration and there has to be a cleaner way than configuring files.

That being said, Hibernate provides me with MUCH MUCH elegant way of programming and interacting with databases rather than JDBC which cannot solve the problem of impedence mismatch between Databases and Java Object oriented world.

Regards
Vyas, Anirudh
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anirudh Vyas:
I don't agree with Configuration XML files used "extensively" by frameworks to do their stuff. It makes the code decentralized and to think that a change in somewhere else (other than my code) code make things work differently gives me shrugs

I sympathize with this viewpoint, I used to think of it that way too. But now I don't. When I write web applications I write some Java code which goes in one place, and some JSP code that goes next to it, and some Javascript code which goes in another place, and there's some CSS stylesheet code which goes in a different place. But it's all "my code". There's also some XML configuration files, and they go in yet another place. They are part of "my code" too, they are just in yet another language. So yeah, my code is decentralized, but it was already that way before. Nothing much has changed.
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well I'd say some of those above de-centralization issues can be solved by using Wicket framework (And yes i agree that not all of us have a choice in the places where we work at ), since it comes closest to Swing for web in development style and it isn't a HACK framework (I consider JSPs as Hack ... believe me when you work with production support and you have to debug JSPs you'd know what i am talking about).

Other decentralization mostly relates to configuration for Dependency Injection (specially in frameworks like Spring), The DI container can be built by using non xml pure Java too, where you would typically register all your dependencies in a factory Map or something (I am skipping the details for clarity).In AOP context, man ... its a nightmare believe me. Beyond those banal use cases of Transaction handling and Logging (which is NOT the ONLY reason why people use AOP ) AOP in XML makes me nervous because i have seen things like change in XML file happen during release support day to make weird things happen when we were showing something to client (it sounds funny now, but then it wasn't, it was all due to a minor change some other developer made in context xml, that we werent able to figure out in our code).

But beyond all the nightmares I do see positives in XML, for example I love XML configuration that Maven has to offer. POM xml gives me one stop configuration to entire application building in a phased way, that is pure and pragmatic...

Just some thoughts ... I agree that Most web projects (today at least) are using component based frameworks that make use of XML a lot which makes your stuff hard to debug and highly de-centralized (Imagine debugging Java script =(, especially those ajax callbacks yuk! )., but i hope that Wicket can show a better way to everyone.

Regards
Vyas, Anirudh
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anirudh Vyas:
Paul,


That being said, Hibernate provides me with MUCH MUCH elegant way of programming and interacting with databases rather than JDBC which cannot solve the problem of impedence mismatch between Databases and Java Object oriented world.



What is Impedence? Can we use the common language?
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
...
As for your political remarks, I don't have the background to comment on them. But I've seen such remarks made repeatedly over the last 5 years or so and they have mostly come to nothing.



Which remarks are political? Can you elaborate?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:


What is Impedence? Can we use the common language?



Impedence is a common term in this forum. There is something called the "Object-relational impedance mismatch" that ORM frameworks exist to help solve. Impedence itself means a kind of resistance and is borrowed from electronics.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:


Which remarks are political? Can you elaborate?



I would presume these:


Java is losing the war to the MS partly because of the various open source frameworks. Sun is falling and powerless to stop something similar to Visual J++ anymore.


This forum not really the place to pontificate on the various merits or otherwise of one company's strategy compared to another. Stick to Object-Relational matters.
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:


Impedence itself means a kind of resistance and is borrowed from electronics.



OK. You mean the Impedance (Z) that is defined as Z(w) = V(w)/I(w), where V is the voltage, I is the current, and w is the angular frequency.
[ April 21, 2008: Message edited by: Elizabeth King ]
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that one for electrical engineering. Only in databases, it's object-relational impedance mismatch (which is easier to search for if you are given the correct spelling of "impedance"). I don't know why the person who originally applied this term to databases used a term from electricity as the analogy.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I mean just "mismatch" between Database models and Object models, is good enough for me.

Mark
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
In the configuration files and the Hibernate code, yes.



Your code includes both Java and XML. So your statement:


The code I had to write was shorter and simpler.


does not stand.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:

does not stand.



OK, at this point, I am classifying this thread as a troll thread.

Your reply of "does not stand" is obviously from never having tried to use an ORM tool or counting the differences in lines typed, because it does stand 100%, and I am talking about 1/5th to 1/10 of the JDBC code versus the xml/annotations/code of an ORM tool.

So this is my last post in this thread.

Elizabeth, my suggestion, just go have fun with all your JDBC code.

Mark
[ April 22, 2008: Message edited by: Mark Spritzler ]
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:

... I am talking about 1/5th to 1/10 of the JDBC code versus the xml/annotations/code of an ORM tool.
...


Mark, Where is the statistics from?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elizabeth King:

Mark, Where is the statistics from?



From over 10 applications that I have personally worked on. Ranging from 10 tables, to one application that had over 2000 tables.

Mark
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, the statistic is most probably anecdotal, but I have to back Mark up on this. Its matches my experiences of data access layers using JDBC and those using a framework.

You are, of course, welcome to disagree with the observations made by me and others. Frameworks are not the answer to every situation, but I would suggest they are a good solution for most.
 
reply
    Bookmark Topic Watch Topic
  • New Topic