Re: To hibernate or not to hibernate?
- From: Daniel Rohe <daniel.rohe@xxxxxx>
- Date: Mon, 05 Jun 2006 09:34:34 +0200
drg schrieb:
So far I've understood you have Customer <-> City <-> Province. Where as
a Customer lives in a City and a City can contain many Customers. And
you have a City which is located in a Province and on the other side you
have a Province which is an area with some Cities. Hibernate does the
mapping of objects and their relationships to the database, that's why
it's called ORM.
Exactly.
If the user in your application selects a customer Hibernate can
retrieve the complete object tree from Customer to City and Province. If
I had to populate a combo box with cities already in database then I
would add a method to City which retrieves every City from database.
Another case could be the user has already selected a Province and now
you will populate the combo box with Cities in this Province. Here I
would add a method to Province which returns all Cities in it. In each
case the mapping to SQL queries will be done by Hibernate.
yes, but the question is, suppose I have 10000 Cities in a list.
Hibernate would return an array of Cities, and the ComboBox would call
toString() to display them. On the other hand, if I use JDBC, I would
get an array of Strings, which I *think* would be much smaller than an
array of cities. I wonder what kind of performance I'd be losing by
using Hibernate.
But of course, Hibernate simplifies things because the ComboBox can now
return a city (and a province). With JDBC I would need to write a lot
of extra code to do the same thing.
You can return only the name of the cities with Hibernate (SELECT c.name FROM com.example.City c).
Daniel
.
- References:
- Re: To hibernate or not to hibernate?
- From: Daniel Rohe
- Re: To hibernate or not to hibernate?
- From: drg
- Re: To hibernate or not to hibernate?
- Prev by Date: Re: How to get the data from a huge table efficiently?
- Next by Date: Getting query SQL from a JDBC PreparedStatement
- Previous by thread: Re: To hibernate or not to hibernate?
- Next by thread: How to get the data from a huge table efficiently?
- Index(es):
Relevant Pages
|