File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Why do we need a framework other than JDBC to access DB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Why do we need a framework other than JDBC to access DB?" Watch "Why do we need a framework other than JDBC to access DB?" New topic
Author

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

Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Paul & Mark, You remind me the days when the EJB CMP was hot...

I'm open mined, but never select technologies because they are "new or hot"

We will see how annotations play
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Originally posted by Elizabeth King:
Paul & Mark, You remind me the days when the EJB CMP was hot...

I'm open mined, but never select technologies because they are "new or hot"



If you read through this long discussion, no one said that they use ORM frameworks just because they are new or hot. Infact, ORM itself has been around for long time now.

Everyone in this thread has tried to explain the uses and reasons why they use these frameworks. They have also noted that its finally upto you to decide whether ORM framework suits your application or not.


[My Blog] [JavaRanch Journal]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Jaikarin,

This is why I am thinking this is more of a troll like thread. Because while Elizabeth is saying she is open minded, she has already made up her mind, because all her "quotes" and "arguments" are all fallacies and made to illicit a big argument.

What everyone else seems to have done is take it as such and we are all taking the high road of saying to Elizabeth, that whatever is her decision or opinion is 100% fine with us, we won't try to change your mind, you get to decide and live with whatever you choose.

Don't think I have anything against Elizabeth. I like Elizabeth, so whatever she chooses, and if she ever has any problems, I will be the first to help out. JDBC or ORM related.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Mark Spritzler:
... I like Elizabeth, so whatever she chooses, and if she ever has any problems, I will be the first to help out. JDBC or ORM related.


Thanks Mark, I like you too. Obviously you have a lot of experiences in this area. The philosophical guide in my architecture is the so called 3S principle.
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265

I'll add a "me, too" to Mark and Paul's comments. Once you get the hang of a tool like Hibernate, it's painful to have to go back.

I've had to go back to a project that's all in JDBC, and it's really put a crimp in my productivity. Even when you can use Spring's JDBCTemplate, it's magnitudes more painful than using a well-designed ORM framework.

And don't forget -- one of .NET 3.5's biggest new features is LINQ, and LINQ is, you guessed it, an ORM implementation. I was just at a launch party and watched hardcore .NET folks nearly jumpint for joy when they saw how little code they had to write now over ADO.NET.


There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Elizabeth King:
One architect from a famous IT company said that they had over 500 hundred tables in their DB and a


I would never make it as a salesman, as I tend to tell the truth too often. Having over 500 tables in a database is a disaster. Its going to be unmaintainable no matter what "silver bullet' you think will work. See Brooks, No Silver Bullet.

I've written at least ten ORM tools over the past 30 years, in nearly every language for nearly every database.

I think they are all way oversold. Hibernate almost appeals to me, since its very lightweight. I've bought into the 'lighter, faster java' karma

But I think Elizabeth is asking the wrong question. Applications programmers and web developers should be using business objects specific to the application domain. They should have no idea how the relational database records get into the business objects.

Done properly, only a tiny portion of the team needs to know about, let alone worry about the ORM.
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Pat Farrell:

...
But I think Elizabeth is asking the wrong question. Applications programmers and web developers should be using business objects specific to the application domain. They should have no idea how the relational database records get into the business objects.

Done properly, only a tiny portion of the team needs to know about, let alone worry about the ORM.


This question is for any developers who work on DAO, which can be based on JDBC, Hibernate, or others. I do not think only a few team members need to know DAO. Many developers are all-round. They can do RIA client, EJB, and DAO. We divide work by use cases, not by logical layers.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

I'm not going to try to tell you how to organize your efforts, but we organize assignments by layers, with pure graphics look and feel (and human interaction) at one end, JSP in the middle, and deep database binding and transaction logic at the opposite end from the user.

I have found that the skill sets vary too much to find one person who can do all of them. It takes geeks who care about race conditions for the guts, and folks who can communicate with other humans on the front end stuff.

There are, of course, exceptions to the rule, but I've had much better luck with layered assignments. With this, most folks just don't need to care about this stuff.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

I'll add my 2 cents that I generally agree with the need for some sort of framework. JDBC is just too low level to be productive when more productive tools exist. I'd be willing to bet that even those who think JDBC is all they need have built some sort of wrapper (framework) around it to make things easier on themselves, yet those same people will slam any main stream framework for doing the same thing.

I'm not a hibernate/JPA fan by any means. At the same time I don't question those (well, not seriously, I joke about it often) that use it and find it beneficial. I think most of use (and I mean the JavaRanch community) are smart enough to not use something just to be buzzy. I generally use iBatis which keep in mind is not an ORM but simply a sequal mapping tool. Its kind of a middle ground between full blown ORM and JDBC.


GenRocket - Experts at Building Test Data
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Gregg Bolinger:
I'll add my 2 cents that I generally agree with the need for some sort of framework.


So rather than the obvious "which one is best" question, I'll ask:

What criteria are important in a framework?
Tejas Jain
Ranch Hand

Joined: Mar 04, 2008
Posts: 119
Originally posted by Elizabeth King:

The philosophical guide in my architecture is the so called 3S principle.


What is the 3S principle?


"Knowing is not enough, you must apply... Willing is not enough, you must do."
--Bruce Lee
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Pat Farrell:


So rather than the obvious "which one is best" question, I'll ask:

What criteria are important in a framework?


For me the framework needs to be light weight and unobtrusive. It should try and do a handful of things really well and leave everything else to other frameworks (no full stacks for me). It should have a low learning curve so that my time is spent getting work done and not figuring out the framework (which is why in the past Hibernate has been shelved for me).
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I think it just comes down to the fact that most applications have to do similar things. Frameworks allow us to leverage the experience and commonality that exists between most applications.

Simple, easy, and solves the problems that I'm likely to encounter. That's what a good framework will do and be.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2061
Originally posted by Elizabeth King:


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?


I think, Elizabeth, you are trying to architect or design something? Or at least looking at these issues on that level?

If I am to make the decision, I would make a very good one, because I know those technologies at a deep level.

I understand that you may be having these doubts as you dont know the details.

It may be too much to suggest, but, you can try build a big, say, 20 jsp 20 servlet, 5 tables jdbc application. And then, build the same using an orm or ejb 3.

You will have a definite answer after that.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2061
Originally posted by Elizabeth King:
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 ]


With regards to framework, I disagree with your comment.

My development in my recent project was faster by at least 5 times, because I used EJB 3 and struts 2, instead of just jdbc and plain jsp. And less errors. Less code. I slept better, and enjoyed my lunch better.

Now I am looking forward to see how jsf can help me.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

enjoyed my lunch better


That is truly the mark of a great framework. Forget about all the rest. If your lunch tastes better, then go for it.

Mark
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Pat Farrell:

What criteria are important in a framework?


A good framework should make a hard development or maintainess task easy and make an easy task easier (at least not make an easy task harder). We have seen some frameworks that make a simple work complex.

A good framework should have new substance, not just emulate other's architecture with a new set of API, configuration, ... . For example, ******MVC emulates Struts1 while iBaties shows new ideas.

A good framework should be easy to learn and to use, and should not have too many tricks so developers can keep concentrating on the business problems. I do not care the size of the jar files as long as they are easy to keep since both RAM and HD become cheaper and bigger.

We are in an open source era where everyone can create a framework and publish it in a book. All the developers should do it responsibly as we are in the same Java community and have a common competitor: MS.
[ May 01, 2008: Message edited by: Elizabeth King ]
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Jesus Angeles:

..

If I am to make the decision, I would make a very good one, because I know those technologies at a deep level.

I understand that you may be having these doubts as you dont know the details.

It may be too much to suggest, but, you can try build a big, say, 20 jsp 20 servlet, 5 tables jdbc application. And then, build the same using an orm or ejb 3.


If you were doing a 5-month project, you could be 4 months ahead the schedule and save 80% of the budget. lol
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Todd Jain:


What is the 3S principle?


Simple
Straight
Stupid (not Smart) so everyone can understand
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Elizabeth King:
A good framework should make a hard development or maintainence task easy and make an easy task easier (at least not make an easy task harder). We have seen some frameworks that make a simple work complex.


This highlights my distaste for Enterprise Beans and much of the J2EE stuff, it makes simple things hard, and its not clear to me that it makes hard things easier.



A good framework should have new substance, not just emulate other's architecture with a new set of API, configuration, ... . For example, ******MVC emulates Struts1 while iBaties shows new ideas.


I don't have any idea what the word is hidden by your asterisks.

I'm not sure that new ideas are important. I've written OO to RDBMS frameworks many times, nearly all have the same idea, map some business objects 'painlessly' to a RDBMS schema.

The problem is that there is not a good fit for many of the fundamental ideas of OO. and we seem to be stuck with relational DBMS no matter what.



A good framework should be easy to learn and to use, and should not have too many tricks so developers can keep concentrating on the business problems.


I would think that no tricks are wanted.

I also dislike the ugly annotations that Java seems to have evolved to think are wonderful. They are clearly a hack stuck on a language to solve problems that were not in scope for the world when Java 1.0 was invented.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2061
Originally posted by Elizabeth King:


If you were doing a 5-month project, you could be 4 months ahead the schedule and save 80% of the budget. lol


Yeah, right. A manager would actually budget 5 months on a 1-month project.

Your statement is conflicting itself.

[ May 03, 2008: Message edited by: Jesus Angeles ]
[ May 03, 2008: Message edited by: Mark Spritzler ]
Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Originally posted by Jesus Angeles:


Yeah, right. A manager would actually budget 5 months on a 1-month project.


I want to work for your manager!!!
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2061
Originally posted by Pat Farrell:


I also dislike the ugly annotations that Java seems to have evolved to think are wonderful. They are clearly a hack stuck on a language to solve problems that were not in scope for the world when Java 1.0 was invented.


I also felt that the annotations was a little bit out of the direction that java seems to be going. It is like a dirty fix, to be able to use java beans. Most likely, there will more future changes that will improve the structure bent on accomplishing this task (on java beans), and on improving related frameworks.
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Originally posted by Elizabeth King:


If you were a saleswoman or salesman for one of the frameworks, what would be your sale point for JPA, Hibernate, JDO, TopLink, iBATIS, ...?



CodeFutures has a product that supports a range of the competing options via DAO- straight JDBC DAO, Spring DAO, Hibernate DAO, JPA DAO, etc. We've just dropped JDO support.

Given that we're framework-neutral, I can tell you that we've had huge success with our Hibernate support in the past and lots of demand for our new Spring feature. However, the vast majority of FireStorm/DAO users tend to use straight JDBC. We'll be doing another user survey in a few weeks and I expect I'll publish the statistics.

If straight JDBC is an appropriate option (it's not always), the key to successful use of JDBC without a framework is to use a code generator.


PJ Murray -
Desean Clayton
Greenhorn

Joined: May 29, 2008
Posts: 2
I have been developing since 2001. I learned early on that pure java is supposed to be best. I just picked up a project that deals with 4 tables with 20 columns per.

I just learned how to use Hibernate at the same time and thank goodness!
1. I didn't have to count spaces when supplying parameters in sql inserts.
2. I avoid sql injection attacks (I believe) just by using hibernate's hql.
3. I can easily change my code by adjusting my mapping file.
4. Hibernate generates the code that relates to my object.

And this is just the 1st 1,2 weeks!
[ May 29, 2008: Message edited by: Bear Bibeault ]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2061
[Edit: not-so-nice comments removed]
[ May 29, 2008: Message edited by: Bear Bibeault ]
Don Solomon
Ranch Hand

Joined: Jul 20, 2008
Posts: 48
Yes, I am dating myself as a Dinosaur but Rogue Wave DBTools was so easy.


Software development is an exercise in thinking not coding.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Did anybody know about NHibernate? I don't think that anyone would port something - just because its hot - to another different platform. There must be a need, I believe.

Annotations are coool. I didn't need to go back to xml to change the fully qualified path of my classes, when I change the package structure of the project.
jim cato
Greenhorn

Joined: Jul 15, 2008
Posts: 21
Elizabeth,
I suggest, since you like JDBC, you try using the SPRING framework which allows the power of JDBC while removing the complexity of implementing a low level API.

Spring overview

Cheers,
Jim
Ravikiran Vishnuvajhala
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
Originally posted by Elizabeth King:
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 ]


I can also argue that instead of learning JDBC, I can directly learn ORM tools to perform the operations required to be supported on a persistance store as opposed to learning both. That way the learning curve would remain the same. I don't think learning this additional tool is a big deal.

One thing we need to accept is that programming evolves with time. And we need to be adaptive to that. Every aspect of application development has tools that we can use to write and build our applications.

Thanks
Ravi
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Ravikiran Vishnuvajhala:
I can also argue that instead of learning JDBC, I can directly learn ORM tools to perform the operations required to be supported on a persistance store as opposed to learning both. That way the learning curve would remain the same.


Its not about making contradicting arguments. BTW, I am not on the other side, but I wouldn't agree here.
[ July 22, 2008: Message edited by: Adeel Ansari ]
jerry bate
Greenhorn

Joined: Jul 22, 2008
Posts: 1
Originally posted by jim cato:
I suggest, since you like JDBC, you try using the SPRING framework which allows the power of JDBC while removing the complexity of implementing a low level API.



Can anyone recommend this from experience?

I'd love to know whether people are using the Spring JDBC Support classes as a one-stop shop to handle all the CRUD and complex querying on medium to large systems.

What I'm wondering is: although Spring JDBC appears to take a lot of the drudgery out of using JDBC, does it give you enough in practise to use it as an alternative to Hibernate/iBatis? I guess this may depend on the type of application, of course. Obviously, Hibernate gives you the ability to pull in complex graphs of objects by using its mapping files, but one often doesn't want to do that anyway.

(Background:
I'm thinking about the architecture for a system that will have about 25-40 tables, and will use basic CRUD, but will also have to construct heavy queries for online searching. In the past I've used Hibernate, which I'm ambivalent about, I've used JDBC directly on a small system (and wouldn't want to do that again), and have written a couple of small persistence frameworks for a couple of projects (I can't re-use this).

For constructing queries, in the past I've assembled JDBC directly in code, and my colleagues have used iBatis successfully. I don't have the option of encapsulating complex queries in PL/SQL unless I can demonstrate this is the only way to get fast enough results).
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
Our book, which is on promotion this week, covers the topic of this thread. We find that most people who go off with plain JDBC, end up inventing something like iBatis or pureQuery. If you like SQL, a framework like iBatis or pureQuery can remove much of the boiler plate code you write by hand with JDBC (Connection Grabbing, ResultSet Looping, and Error Handling). A framework can help eliminate code you will find yourself writing again and again.


Roland Barcia: IBM Distinguished Engineer, CTO Mobile for Lab Services
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why do we need a framework other than JDBC to access DB?