Re: To hibernate or not to hibernate?



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
.



Relevant Pages

  • Re: To hibernate or not to hibernate?
    ... or should I use Hibernate to take care of the DB stuff? ... I have a Customer object and can pass data ... City and Province objects (I would use String city and int cityId, ... Imagine I have a list of cities ...
    (comp.lang.java.databases)
  • RE: Attention Ken Sheridan
    ... is the correct row or would assume that there are cities called San Francisco ... LastName and City fields do meet this criterion ... "I have all 200 of our stores in one table" ... Each store relates to one hub only, but two stores in one City say, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: WC2014 host cities
    ... the two "green" hosts are ... city], and Cuiabá is an Amazon region city more than anything else. ... cities who support football better than them (I'm thinking here the ... As for the elimination games, ...
    (rec.sport.soccer)
  • Obama to bulldoze your city
    ... Dozens of US cities may have entire neighbourhoods bulldozed as part of drastic "shrink to survive" proposals being considered by the Obama administration to tackle economic decline. ... The government looking at expanding a pioneering scheme in Flint, one of the poorest US cities, which involves razing entire districts and returning the land to nature. ... Local politicians believe the city must contract by as much as 40 per cent, concentrating the dwindling population and local services into a more viable area. ... Having outlined his strategy to Barack Obama during the election campaign, Mr Kildee has now been approached by the US government and a group of charities who want him to apply what he has learnt to the rest of the country. ...
    (misc.survivalism)
  • populating one combo box based on another
    ... I have a table called state that lists states. ... THis table contains states and then cities within each state. ... I create a form based on the customer table but omit the city and state ...
    (microsoft.public.access.formscoding)