FAQ
Hello,



anybody has experience with using MyFaces together with Hibernate?



Thanks

Rene

Search Discussions

  • Glenn Davidson at May 25, 2005 at 3:01 pm
    Rene,
    I have been using Hibernate and MyFaces together with great success. The intergration is seemless and was actually quite easy to implement. I am having trouble with some very complex queries but I attribute that to the fact that I am still relatively new to Hibernate. The two work together well.

    Glenn

    Rene Guenther wrote:

    Hello,



    anybody has experience with using MyFaces together with Hibernate?



    Thanks

    Rene


    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
  • Hendrik Neumann at May 25, 2005 at 3:06 pm
    yes, it works fine! But afaik Hibernate and MyFaces "don't touch" each
    other... so I would be a little bit confused, if anybody experiences any
    problems...

    Am Mittwoch, 25. Mai 2005 16:51 schrieb Rene Guenther:
    anybody has experience with using MyFaces together with Hibernate?
  • David Tashima at May 25, 2005 at 3:11 pm
    Well the way I use it, I persist the same beans that are bound to UI
    elements, so when you change UI elements, you're changing the actual
    thing that ends up being persisted into the DB.

    The tricky part is to 1) close your Hibernate session with a servlet
    filter; 2) you have to reassociate the object to the current session
    before saving (just b/c the ID of an object corresponds to something
    that lives in the database, it won't automatically figure out how to
    save stuff).

    -Dave
    On 5/25/05, Hendrik Neumann wrote:
    yes, it works fine! But afaik Hibernate and MyFaces "don't touch" each
    other... so I would be a little bit confused, if anybody experiences any
    problems...

    Am Mittwoch, 25. Mai 2005 16:51 schrieb Rene Guenther:
    anybody has experience with using MyFaces together with Hibernate?
  • Werner Punz at May 26, 2005 at 4:27 pm

    David Tashima wrote:
    Well the way I use it, I persist the same beans that are bound to UI
    elements, so when you change UI elements, you're changing the actual
    thing that ends up being persisted into the DB.

    The tricky part is to 1) close your Hibernate session with a servlet
    filter; 2) you have to reassociate the object to the current session
    As for the closing, no servlet filter is required...
    you can do it with spring as well, spring has mechanims for that
    in place which you can introduce on DAO level.
    before saving (just b/c the ID of an object corresponds to something
    that lives in the database, it won't automatically figure out how to
    save stuff).
    Yes reassociating is necessary, but the beauty of the hibernate-jsf
    combo is, that you just shift the plain database objects around
    and even significant name changes on the db side wont affect your
    controls, like it usually is a problem with plain relational control
    mapping, because you can cover that on the hibernate.xml config file
    level in the worst case.

    The main problem I faced with the integration of hibernate into
    the JSF context was, to figure out how to deliver data
    into a data table until somebody gave me the hint of implementing a
    hibernated DataModel class.

    The main problem with the DataModel is, that the API is just plain awful
    in a Hibernate context if you follow the approach of keeping connections
    open just for short periods of time.

    I basically had to preload the data into a chache due to API constraints
    of the datamodel and deliver the Hibernate POJOs from the cache into the
    forms (and refill the cache if I run out of objects), and I did not have
    a chance to get the current pageSize directly, so that I could
    adjust my internal prefetch cache.

    The main problem simply is, that the api follows a flow like that:
    a) first set the init params, request the number of possible objects
    then
    call give me an object from the model
    increase the internal position counter over a separate object
    and so on

    If you want to fetch as much objects as possible within one
    transaction/session boundary, this approach is plain awful, as I said.

    It would have been easier for everybody with a workflow like that:
    set the init params, request the size

    request objects x-y from the model and rerequest the size

    That way you could use paging on the mapper level....

    To sum it up, the API for the current JSF datamodel, simply and
    plainly stinks (but so does the API for custom controls as well)!
    This is JSF after all, once you leave the high level of good components
    you basically run into API and code artefact hell at every level :-(
  • Werner Punz at May 25, 2005 at 5:21 pm

    Rene Guenther wrote:
    Hello,



    anybody has experience with using MyFaces together with Hibernate?
    Works very well, they dont touch each other, the trickiest part is, that
    you need a hibernated DataModel if you want to use a
    Datatable... Datascroller

    Besides that it is much better than plain JDBC, because Hibernate does
    the ORM stuff for you, all you gotta do is, to fetch your hibernate
    objects and bind them directly to the controls, one way or the other,
    later bind them to the session again and do the Database stuff.

    Werner

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 25, '05 at 2:52p
activeMay 26, '05 at 4:27p
posts6
users5
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase