Re: How to best use Hibernate



Snyke <Decker.Christian@xxxxxxxxx> wrote:
Ok I have a business application which has persists its data to a
database using hibernate. What I want to know is what is the best
practice for persistence?
- Load it all into memory and then synchronize to the database.
- Load only parts out of the persister, modify it and then save it
back to the database.
- Hybrid of those, loading into memory changing it there,
synchronizing it to the database but leave the data in memory so I
don't have to reload it again.

Obviously the last option has a lot of overhead, because of its dynamic
loading, the first is my preferred one, but am I using all the
potential of Hibernate, and is the effort managable for lots and lots
of data? The second is what looks like a standard solution, but doesn't
the Hibernate stuff add a lot of overhead to this one too?

First of all, Hibernate doesn't add "a lot" of overhead to very much.
The product writes nearly optimal SQL in most cases (some minor
exceptions, such as outer joins with PostgreSQL pre-8.2 as was pointed
out to me recently). Certainly the computational work of Hibernate
itself is trivial next to talking to a database.

Next, how much you modify prior to updating the database should be
determined first and foremost by the transactional boundaries of the
application. Hibernate has plenty of nice caching options, so you don't
need to let database performance issues dominate your system
architecture by trying to load and keep all this data in memory
intentionally. The cache does that. You can just write code to do what
you want.

That's the best I can do from your question. You'll get better answers
if you're more specific.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.



Relevant Pages

  • Re: Memory leak
    ... Load a large DataSet from the database. ... Before loading the DataSet the MemUsage column in Task Manager shows 44 MB. ... I've found a discussion where a claim is made by someone else that DataSet doesn't release memory, but nothing specific is offered. ...
    (microsoft.public.dotnet.languages.csharp)
  • BULK Processing Process "Expires" without completing
    ... I'm going to have more tables to load - I don't want to do what the current ... Is it possible that somehow I'm running out of memory and not completely ... I should also point out that up to now nobody has tried to write packages ... against this database and I'm not completely sure the database is configured ...
    (comp.databases.oracle.server)
  • Re: How big can an array be ?
    ... > Is there any limitation to a PERL array size? ... > If I was to load a MySQL database into an array... ... You probably can't load more into memory than what can be fit ...
    (comp.lang.perl.misc)
  • optimizing memory utilization
    ... "database" for other subsequent processing. ... album ID an the CDDBID. ... When I load into memory, ...
    (comp.lang.python)
  • Re: Database Backend?
    ... and a decent database ... As best as I can tell, Hibernate is the current best of breed. ... java code on the page, and that is a big pain to maintain. ... Tapestry is a very clean framework, but it takes a while to figure out. ...
    (comp.lang.java.programmer)

Loading