Re: How to best use Hibernate




Snyke 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.

Depends on what "all" represents i.e. the underlying datastructure. For
e.g. if you are updating a tree structure of objects, does all
represent the entire tree, or a leg of the tree that matches the update
condition ?

- Load only parts out of the persister, modify it and then save it
back to the database.

Same question as above.

- 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.

When manually done, the potential for buggy code is quite high in this
style.


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?


Hibernate does take care of the hybrid quite nicely, goes well with
many web frameworks, provides caching, takes care of create/update
scenario etc. Works quite well for us.

There are also other options like Castor etc that provide Object to DB
mapping via configuration and away you go writing business logic,
leaving the worrisome db coding, connection management etc to these
frameworks.

--
Arvind

.



Relevant Pages

  • 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)
  • Re: in memory db of 200 GB
    ... > that stores the whole database in memory ... > (using a persistence layer as hibernate in order to manager ...
    (comp.lang.java.databases)
  • Re: acceptable way to program
    ... I'm an experienced database programmer learning the ... > Java/OO way of doing things and I'm puzzled that people use Hibernate ... There is undoubtedly some bad database programming being done by Java ... As for stored procedures, it is true that current production releases of ...
    (comp.lang.java.programmer)
  • Re: [Help] Struts/JSP -- easy way associate an "ID" to a "Value"?
    ... >> database and started business flow on it) all the data. ... so I'll probably look into using that to synchronize a Map. ... and I can easily save them using Hibernate. ... > validation framework ensures the values written from the HTML form into ...
    (comp.lang.java.help)
  • Re: What does everyone else do for graphically displaying data?
    ... JDBC API reference cover to cover a couple of times, ... you bind a data grid to a database table so that when you edit the ... put all JDBC code in the Model classes. ... Use something like Hibernate. ...
    (comp.lang.java.databases)

Loading