Announcement Announcement Module
Collapse
No announcement yet.
hibernate alternative Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hibernate alternative

    Hi,

    i search for a alternative for hibernate, because my session binding, DB Connections problems und cache Problems with hibernate will not end.
    the alternative i search should have the following requirements:

    - ORM, simple working with pojos withount knowing of the persitenz tier.
    - lazy loading of complex objects, but wihtout caching or session binding. so every call to a "getComplexObject" p.e. getItemlist() should send a query to the database.

    did anyone know a good solution ?

    or what about db4objects? it looks realys fast but what about the memory and lazy loading, did someone know of this?

    thank you verry much

    yours sincerely
    Gideon

  • #2
    DB Connections problems und cache Problems with hibernate will not end
    Did you try finding a solution here or on the Hibernate forum?

    did anyone know a good solution ?
    You might find something in these links. The first one has a feature matrix.

    http://c2.com/cgi/wiki?ObjectRelationalToolComparison

    http://www.javaskyline.com/database.html

    Comment


    • #3
      Gideon,

      There are no problems... only challenges!

      One tool that seems to growing - I have not had a chance to try it out yet though - is Cayenne. It has been active for quite some time, but I don't know of very many users (other than the NHL). Although it is in the incubator status over at Apache, it is 'mature' (Object Style has developed it for a while).

      I would love to know if anyone has used Spring and Cayenne together!

      Good Luck,

      Steve O

      Comment


      • #4
        Hi,

        thank you the links, the looks, good.

        yes have have searched for solutions, but i havent found one. maybe its my architecture or my misunderstanding of hibernate and spring, or both.

        my architecture looks like this:

        Objekts:

        User
        PrictureLibrary
        Picture

        user.pricturelibraryS

        pictureLibrary.user
        pictureLibrary.pictureS

        picture.picturelibrary
        picture.user

        now i do the following:

        the user logs in with over acegi, (here is lazy loading requried for the User Authorities), at this point i think i can renounce the lazy loading of this collection because it will ever be loaded.

        than he can do 2 main things:

        looking the pictures:
        here i call

        1. :user.getPictureLibrary () (this is the "first" step where lazy loading is definitly required, the problem is that login and showing the pictures is more than one request, normel hibernatesession in Spring only supports one request, at hibernateforum i found a solution, which is called long session, where i save the hibernate session in the httpsession.)

        2. now i call, picturelibrary.getPictures() (this is in the same step as step 1. so here lazy loading should make no problems)

        3.
        now the picturemap is send to the view, there i iterate over, and call:
        picture.getId() (this should be no problem, but now the image will streamed to the browser in step 4)

        4.
        this is a servlet the maps to all jpeg request.
        the servelts then calls:
        pictureDao.getPicture(byId), after this: picture.getPictureLibrary(),
        and than: picturelibrary.getThumbview(), (i need this to find the real image on the filesystem) ( here lazy loading is required, the problem is that the, jspview have a hibernate connection, and is one request, every call to the servlet for streaming a image is a second request, and there are many of this request parallel, so for lazy loading i need again a long hibernate session. ) so far this works, it theorie well, but the problem is, that between the many parall request, the hibernate session will be commit on sometimes between the request und so the other parallel running request throw a exception.

        for this problems i have tested many things:

        all Flushmodes, where flushmode.allways seems to work, but then i have a sql query for every picture, and that is not what i want, with this i don't need: picturelibrary.pictureS
        and if i recall reight, the pictutes where not inserted correctly to the DB (the index column for the Array index is not updated)

        appending alle needed parameter for the image servelt as paramter, this works well, but with this, every user knows the correct path to the picture in the filesystem, and i don't have a securitycheck if the user is allowed to view this picture.

        using no SpringHibernate TransactionManager and TransactionProxy.

        this works well when viewing the pictures, but when i will add a new picturelibrary i get a exception, that i have the change the transaction to read write (exceotion says the object can't sored becaus readOnly permisson) but i don't know where i can change this, and i think using transactions is more safty.


        the second big think the user can do ist adding pictures.
        here the user do the following:

        1. logging in, over web or over SpringRemote (lazy loading problem is the same as above in step one)

        2. selecting a picturelibrary, over the call: user.getPictureLibraryS (here lazy loading is requried, it should be no problem becaus the intercepor can do this, in this one request)

        3. if the file is stored, a quartz job will be created.
        this job, will process the images, for this the job calls:
        picturelibrary.getThumbview() (the picturelibrary object is stored in the jobdatamap, the information is needed because the job must know how to process the images, here lazy loading is required, the problem is that the quartz job is on another thread. i found a solution for this, with the long hibernatesession, where i store the session in the jobdatamap, and the bind the the session to the thread, its like the same as openSessionInViewInterceptor do this,)

        4. than this job will create a next quarzt job, this job will insert the picture into the DB. for this he calls:
        new Picture
        picture.setPictureLibrary
        pictureLibrary.addPicture

        pictureDao.savePicture
        pictureLibraryDao.savePictureLibrary

        here lazy loading is still required, for adding the pictutes to the library.

        the only solution i found for this, is the Long HibernateSession, which i handle at start and ends of the jobs.

        did anyone see a mistake at my architecture? or configuration?

        other things i tested was calling. pictureLibraryDao.getPicture(byID)
        but here i get exceptions, like, that hibernate can't attach one object to two open sessions, or something like that.

        the next steps i will do are the following:

        deleteting, user.picturelibrary
        so i musst call :
        pictureLibraryDao.getPictureLibraryS(byUser)
        so lazy lading of user.getPicturelibrary will be eleminated, dont know if this is a good and the right soltion.
        creating a jdbcDao special for the imageservelt and the quartz jobs. (dont know if this is right and good, i think this is bad becaus whith this i leave the objectworld know i call, picturelibrary.getView() after this changes i call: quartzDao.getViewInformations, where the result of this is only a list of Strings, not a View Object).

        maybe someone can give me a hint how to solve my problems good and right.

        thank you verry much

        yours sincerely Gideon

        Comment


        • #5
          Originally posted by Steve O
          Gideon,
          There are no problems... only challenges!
          yes thats, right, but the page have to be finished (because my holidays come further and my local disk don't have much free space).

          thanks for the hint i will take a loot at this.

          ys
          Gideon

          Comment


          • #6
            Originally posted by Gideon
            1. :user.getPictureLibrary () (this is the "first" step where lazy loading is definitly required, the problem is that login and showing the pictures is more than one request, normel hibernatesession in Spring only supports one request, at hibernateforum i found a solution, which is called long session, where i save the hibernate session in the httpsession.)
            Why do you use a long session? You could use the OpenSessionInView pattern, if you want to use lazy loading in the view layer.
            I use a session per request pattern, that is the recommended pattern. So in this case in my controller class I will reload the entity that has a method with lazy loading.

            Comment


            • #7
              hi,

              Originally posted by aleruz
              Why do you use a long session? You could use the OpenSessionInView pattern, if you want to use lazy loading in the view layer.
              I use a session per request pattern, that is the recommended pattern. So in this case in my controller class I will reload the entity that has a method with lazy loading.
              yes if i change the architektue, with removing the PictureLibrarys from the Userobjekt, i can use the session per request pattern, with the openSessionInViewInterceptor,

              but the problem is, that this will not work for loading the images because, the request for the imageServelt is a second request (the first is the request for the view which force the browser (over the <img> tag) to do the second request.

              or maybe changing the architekture as described above, should solve the session problems
              so far if noone have a better hint idee etc. i will do this and see if theorie and praxis are the same.

              thanks

              ys Gideon

              Comment


              • #8
                Extensive use of Cayenne

                Has anyone happened to use Cayenne extensively, ie, like in a production system where it completely replaces any other ORMs. Had a look at it and its more like a hybrid of Ibatis and Hibernate. If anyone has been using it please let me know.


                Thanks,
                Franklin.

                Comment


                • #9
                  i don't really get what's the problem here, why do you have to remove the PictureLibraries from the User in order to use OSIV? btw. there is no problem with the long conversations, but beware that the default spring behavior is closing the connection to the db only when you close the session, so you can run out of connection really soon.
                  try to describe a simple scenario, what are you trying to achieve and where it is not working...
                  also i really recommend the java persistence with hibernate book if you want to do some serious programming with jpa/hibernate

                  Comment


                  • #10
                    This problem did sound very complex for something that should be pretty straight forward. This thread, is quite old now though.

                    Comment


                    • #11
                      What about iBatis?

                      We are using iBatis 2 with spring for a high traffic webapp and it never let us down. It's fast, straight forward and easy to learn. If your database can do it - iBatis can do it as well. IMHO it is the right choice if you don't need OO queries, polymorphic associations or other 'esoteric' OO features - it's a thin layer over SQL but its a true ORM with object caching and many more goodies. See the comprehensive feature comparision at http://c2.com/cgi/wiki?ObjectRelationalToolComparison to see if it matches your demands - iBatis and hibernate are just next to each other

                      I introduced it to the project mentioned above and no other team member knew it but they all got into it very soon. The mapping files are very self explanatory. AFAIK myspace.com is running iBatis, well...

                      Comment


                      • #12
                        There's always JPA, choose whichever implementation you want.

                        Comment

                        Working...
                        X