• 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

Disadvantages of Hibernate

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I have been reading about Hibernate for a few days from now.
I have read about its adavntages, what it is capable of doing, etc.
Today someone at work asked me about its disadvantages. I did not know what the answer was.
Does anyone have an answer to this question ?

Thanks,
-Gayatri
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some disadvantages (or inconveniences) I have encountered so far are

1. Not that flexible when it comes to mapping composite-ids (although you can do a lot). While this is not a fault of Hibernate as composite-ids are typically used in legacy systems, it can be a pain when attempting to map legacy tables.

2. Everything is an object. If you need only a portion of data (say, for a search), you would still have to retrieve the object. However, this is true for any ORM strategy.

3. In some cases, you will encounter the (n+1) select problem. That is, Hibernate will execute (n+1) queries for going through a list of records of size n. There are some mechanisms suggested by Hibernate that can be used to mitigate this risk.

4. Till Hibernate 3, you cannot map multiple tables to a single class. This has been fixed in Hibernate 3 using the join tag.

In general, Hibernate is a very powerful and flexible tool. After using it for 6 months, I see myself thinking about using Hibernate whenever I need to talk to databases (except for extremely simple scenarios).
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, It does not come out of the box with visual tools for editing meta data or relational mapping. Some third party tools provide visualization for specific portions of Hibernate development but no one tool has all the capabilities so several tools must be used.

As far as pricing, the leading JDO vendors offer very attractive pricing models as compared to Hibernate as there is only a marginal cost for development licenses and no runtime charge. It is worth considering a JDO solution in your planning.

Salomon Zalzman
Versant Corporation
www.versant.com
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Salomon Zalzman:
As far as pricing, the leading JDO vendors offer very attractive pricing models as compared to Hibernate as there is only a marginal cost for development licenses and no runtime charge. It is worth considering a JDO solution in your planning.



Isn't Hibernate free? Thus making it the cheaper and more attractive of the two options?
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some people believe the saying "You get what you pay for." Of course, many people also believe that commercial software means good support.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sathya,

1. Not that flexible when it comes to mapping composite-ids (although you can do a lot). While this is not a fault of Hibernate as composite-ids are typically used in legacy systems, it can be a pain when attempting to map legacy tables.


partially wrong, using composite-id seems much harder but it isn't and of course it is possible to map composite-ids

2. Everything is an object. If you need only a portion of data (say, for a search), you would still have to retrieve the object. However, this is true for any ORM strategy.


wrong, HQL example: select person.name, person.height from com.Person, it doesn't return an instance of Person....

3. In some cases, you will encounter the (n+1) select problem. That is, Hibernate will execute (n+1) queries for going through a list of records of size n. There are some mechanisms suggested by Hibernate that can be used to mitigate this risk.


again, with fetch keyword and batch-size you cannot have a n+1 problem, a (n/batch-size)+1 problem... maybe

Salomon,
hibernate tools are in progress, i always think it's better to focus on the core features than in the visual artifacts...
My POV is that mapping editor + schemaexport are sufficient to have a great productivity

last, hibernate is free but if you need professionnal support (which is normal) you can get strong expert support from JBoss.

Hope this help,
Anthony
Hibernate
[ March 04, 2005: Message edited by: anthony patricio ]
 
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


quote:
--------------------------------------------------------------------------------
2. Everything is an object. If you need only a portion of data (say, for a search), you would still have to retrieve the object. However, this is true for any ORM strategy.
--------------------------------------------------------------------------------


wrong, HQL example: select person.name, person.height from com.Person, it doesn't return an instance of Person....


What does it return then, if not an Object?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example,

would return an Object[] of two elements of type java.lang.String.
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an interesting article about ibatis sqlmaps as a more low level alternative.
http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html
I interpret low level as less confusing at first, probably more maintainance-work in the long run and generally more handcoding.

If you don't know the database very well, hibernates transparency might make problems difficult to spot. I have shot in my shoe at weekend, while trying to create tables in HypersoniqSQL-DB with hbm??? tool (the tool to generate RDBMS tables from hbm.xml mapping files).
I think the source of the problem was that I've used long datatype in an identy column. Only Integer appears to be allowed. Haven't found no log-messages which explained that.
I like hibernate a lot and hibernate in action was a sometimes challenging but very good read last year. Nevertheless I'ld recommend to not see hibernate as the "hammer" for all "rdbms-issues" in java.
Better to diversify knowledge about rdbms-integration issue like EJB-Entity beans, ibatis sqlmaps, self-written more-or-less-ad-hoc-frameworks and more conceptual stuff which is not bound to a special framework (like optimistic/pessimistic locking, DAO-Pattern, know-features-of-DB-you-are-using well)

Axel
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi chris
Even JPOX is free
Thanks
kundan
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my 2 cents:


2. Everything is an object. If you need only a portion of data (say, for a search), you would still have to retrieve the object. However, this is true for any ORM strategy.



You can use projection to retrieve only part of a mapped entity. Assume Person has a number of properties (Address, Phonenumber, ...,name and age) :

NOTE: Does not work with collections (at least in Hibernate 2, i do not know if Hibernate 3 can handle them).


3. In some cases, you will encounter the (n+1) select problem. That is, Hibernate will execute (n+1) queries for going through a list of records of size n. There are some mechanisms suggested by Hibernate that can be used to mitigate this risk.



You can use [url=http://"http://www.hibernate.org/hib_docs/api/net/sf/hibernate/Criteria.html"]setFetchMode()[/url] , eager fetching in HQL, outer join settings to control the way collections are loaded.



pascal
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pascal betz:
my 2 cents:

NOTE: Does not work with collections (at least in Hibernate 2, i do not know if Hibernate 3 can handle them).



You can use [url=http://"http://www.hibernate.org/hib_docs/api/net/sf/hibernate/Criteria.html"]setFetchMode()[/url] , eager fetching in HQL, outer join settings to control the way collections are loaded.



pascal



I have a few little questions about the "select new" : How does it work ?!
does the object we want to instanciate have to be declared in an hbm.xml file ?
is it possible to do a "select distinct new ... " ?
Help... I don't find any info, even in Hibernate in Action...

Brice.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a few little questions about the "select new" : How does it work ?!
does the object we want to instanciate have to be declared in an hbm.xml file ?
is it possible to do a "select distinct new ... " ?
Help... I don't find any info, even in Hibernate in Action...

Brice.



Hi Brice,

Look under �7.4.1, "Projection" in HiA (p. 271 in my copy :-).

The result class does not have to be a mapped class ��I think the only requirement is that it have a constructor with a matching profile (or signature or whatever you want to call it).

I do not know if "select distinct new..." is possible. I would expect that it is.

HTH,
�ml�
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic