This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes When should I use JDBC and when to use Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "When should I use JDBC and when to use Hibernate" Watch "When should I use JDBC and when to use Hibernate" New topic
Author

When should I use JDBC and when to use Hibernate

Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

It seems like I have 4 choices of technology of database access in Java:

1. Hibernate
2. JDBC
3. Entity Beans
4. Ensity Bean container

It seems like Hibernate is the right answer. Do you agree?

-- Kaydell
[ November 25, 2006: Message edited by: Kaydell Leavitt ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Kaydell,
It depends on your requirements. There are almost never absolutes about always using a given technology. For example, if you were doing a single complex query, Hibernate would be overkill.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

I can't seem to figure out how to implement UTF-16 CHARS using JDBC.

Does Hibernate serialize objects and then allow the resulting data to be stored in a JDBC database?

I worry about serializations that are stored on a disk or that may become different between client and server such as might be the case when using RMI. Is serialization a problem and does Hibernate use it to map objects into a relational database?

-- Kaydell
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Kaydell,
Since this wound up being more about Hibernate than JDBC, I'm going to move the thread to our O/R forum. They know more about Hibernate and can give you the specifics.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hmmm. why is my response here ? was intended for another post.

pascal
[ November 27, 2006: Message edited by: pascal betz ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

JDBC is good for quick-and-dirty, but ORM is generally preferable for larger, more complex projects. Interestingly enough, even though the ORM projects normally are using JDBC as their underlying access method, benchmarks indicate that they tend to be more efficient than raw JDBC. Like assembly languages vs. HLLs. It may sound paradoxical, but I've seen more than my share of horribly inefficient assembly algorithms used simply because writing a smarter one takes too long.

No, Hibernate isn't using serialization, BTW. It's using JDBC. Part of the Hibernate functionality is to establish a mapping between data objects and SQL objects in the backing database, generate the SQL code needed to access and modify it, and manage the execution of that process.

Just to repeat something I said the other day, however, do try and minimize the number of programs modifying the database at the same time. If only one app changes the data, there's never any question which app is misbehaving.


Customer surveys are for companies who didn't pay proper attention to begin with.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
see my post above. something went wrong here.
Pascal
[ November 27, 2006: Message edited by: pascal betz ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

JDBC is good for quick-and-dirty, but ORM is generally preferable for larger, more complex projects. Interestingly enough, even though the ORM projects normally are using JDBC as their underlying access method, benchmarks indicate that they tend to be more efficient than raw JDBC. Like assembly languages vs. HLLs. It may sound paradoxical, but I've seen more than my share of horribly inefficient assembly algorithms used simply because writing a smarter one takes too long.

No, Hibernate isn't using serialization, BTW. It's using JDBC. Part of the Hibernate functionality is to establish a mapping between data objects and SQL objects in the backing database, generate the SQL code needed to access and modify it, and manage the execution of that process.

Just to repeat something I said the other day, however, do try and minimize the number of programs modifying the database at the same time. If only one app changes the data, there's never any question which app is misbehaving.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When should I use JDBC and when to use Hibernate