Menu

a bunch of questions on different things

Help
sorin7486
2006-11-21
2013-04-25
  • sorin7486

    sorin7486 - 2006-11-21

    Hello,

         I am working on this open source project caled LEBON and we use JSF and Hibernate...The guys from Irian(don't know if you heard about them but it dosen't mather) gave us a bean clonner to work with... The idea is very similar to beanlib... I'll post an anouncement when we commit the latest version of lebon so you can take a look at it... So my questions are these:

         First of all I can't find any good examples for using beanlib... do you know of any open source project where I can see how it works ? ...

         On this(http://hansonchar.blogspot.com/2005_06_01_hansonchar_archive.html) page it says "100% deep clone which will result in eagerly fetching all related entites".. we had a small performance issue in our project in that we had to make sure we eagerly fetch the entitys before clonning if deep clonning is involved so that we can avoid the huge number of querys to the database... dose beanlib handle only the cloning or dose it also handle fetching and in case of deep cloning is it able to use a reasonable number of querys for  fetch ???

         Dose beanlib handle saving ? like if I get a bean from the database and change something in it dose beanlib know what has been changed and save only that piece of information ?

         Point of view... the bean cloner we use makes cloning based on a settings... so we have to create a setting object and add to that  the types and/or property names that we want to include/exclude when cloning.... there is no code involved... I think this is a rather good idea since it offers more flexibility...

         This is a great project by the way and it will be very useful especially to the JSF comunity... for us cloning is a must...

         Thank you

     
    • sorin7486

      sorin7486 - 2006-11-23

      Here is the answer I got by mail from ... maybe someone else can use this information too

      Hi Sorin,

          Sorry to bother you like this but I don't know if you still
          read the help forum...

      No problem and yes I do read the help forum :)

          First of all I can't find any good examples for using
          beanlib...

      I know.  I've been pretty bad on the doc part.  Anyway, please find attached my current presentation draft for JavaPolis 06, but please keep it private until after JavaPolis06 is over.

      I know it's still embarrassing spare...but being lazy is also the reason behind the creation of beanlib.  (See I find yet another excuse.)

          do you know of any open source project where I
          can see how it works ? ...

      Actually I don't know.  Personally I've applied it successfully to many commercial projects.  I am very interested to know as well.  Honestly I created beanlib for my personal enjoyment, but I am also delighted if someone else finds it useful.

          On this( http://hansonchar.blogspot.com/2005_06_01_hansonchar_archive.html\)
          page it says "100% deep clone which will result in eagerly
          fetching all related entites".. we had a small performance
          issue in our project in that we had to make sure we eagerly
          fetch the entitys before clonning if deep clonning is
          involved so that we can avoid the huge number of querys to
          the database...

      One simple thing you can do is to specify in the Hibernate mapping file to eagerly fetch the related entities.  This will allow better performance regardless of beanlib, assuming you know in advance that eager fetching among those specific entities are the right thing to do.  Please read the Hibernate reference manual for more details.

          dose beanlib handle only the cloning or dose
          it also handle fetching and in case of deep cloning is it
          able to use a reasonable number of querys for fetch ???

      I handles fetching but doesn't optimize the query.  To optimize the query you need to do it outside of beanlib such as configuring the Hibernate mapping file.  The beanlib lowest layer is a JavaBean cloning framework.  On top, the beanlib-hibernate layer provides the ability to automatically resolve the persistent entities if they were not yet fetched/realized.

      The programmer (user of beanlib) can then stay as lazy as possible.  My philosophy is to optimize only as needed.  Otherwise, get things done fast by doing as little work as possible.  Beanlib enables this.

          Dose beanlib handle saving ? like if I get a bean from the
          database and change something in it dose beanlib know what
          has been changed and save only that piece of information ?

      You can look at the objects cloned/returned from beanlib as in the "detached" state, using Hibernate terminology.  This means you can update these objects completely outside of Hibernate.  Then once you pass these pojo's to Hibernate and do a session.update(...), the changes will be automatically persisted.  No difference from the usual practice/use of detached objects in Hibernate, beanlib or not.

      In my world, using Beanlib+Hibernate+Spring to build a persistence layer leads to some really simple API that can be implemented fast.  Beanlib let the API completely hides the fact that one is using Hibernate/Spring/Beanlib, as there is no concern of session state.  Just simple POJO, whose classes happen to be those also used by Hibernate for it's persistent objects.  Much fewer classes.  (This is an option though, as one can clone objects between different classes in Beanlib.)

      Hope this helps.

       

Log in to post a comment.