Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Book: Spring/Hibernate.

Hybrid View

  1. #1

    Default Book: Spring/Hibernate.

    Hi there

    is there a book available which has in-depth discussion of the use of Spring and Hibernate together? I am really looking for complex examples of web-applications (for administration of data in a database via a browser GUI), especially with such features as bidirectional collections and lazy-loading.

    I am having a great deal of trouble with the app I am developing right now. One thing is it runs real slow when accessing data. To counter this I try to use lazy-loading, but then I get lazy initialisation exceptions, or objects which are not persisted in the database, for example.

    Thanks,
    Peter

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    I would suggest a good Hibernate book first, like Hibernate in Action. The performance issues are most likely concerned with your data access.

    You could consider using Spring's support for "open session in view" to enable lazy loading, if you're writing a web app.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3

    Default

    Thanks for the answer.

    I am trying to use org.springframework.orm.hibernate.support.OpenSess ionInViewInterceptor to help with lazy-loading in my web-app, but still get "initialisation" problems.

    Without lazy-loading data access is s l o w. This is undoubtedly due to mis-configuration or my misunderstanding of Hibernate. I do have a rather complex object model and matching database - I have a "join table" for many-to-many relations between many different types of objects, and to resolve these and instantiate the correct concrete classes I can see that Hibernate needs to make a huge number of database accesses (presumably to determine the type of object). It may be better to have more specific join tables for each specific many-to-many relation.

    Oops, now I can see I am rambling on....

    Anyway, hence the request for a book dealing with Spring, Hibernate and complex web-applications.

    Peter

  4. #4
    Join Date
    Aug 2004
    Posts
    203

    Default

    Hello,
    Hibernate - Hibernate in Action
    Spring - J2EE without EJB (have chapter about hibernate)

    regards

  5. #5

    Default In addition

    In addition to the books prescribed above, maybe you might be interested in having a look at this blog;http://www.jroller.com/page/kbaum/Weblog ,as it seems one of your main problems is lazy loading.

    HTH

  6. #6
    Join Date
    Aug 2004
    Posts
    203

    Default

    Hello,
    Hibernate one-to-many relations are unusable with big collection (many side) - hibernate don't load or load all rows - when we have a lot rows we get row memory or exception with lazy loading - only workaround is that You don't use one-to-many collection than load many side "manual" with scrollable result set

    regards

  7. #7
    Join Date
    Sep 2004
    Location
    Melbourne, Australia
    Posts
    54

    Default

    You might also want to look at using Outer Join Fetching. It really helps get around the 1+n problems. And Hibernate in Action has a good section entitled "Retrieving objects efficiently" that is definitely worth a read.

    Outer joins fetching is a little tricky if you're new to Hibernate. Especially if you want to fetch more than one one-to-many association at a time (by default Hibernate only allows one outer join fetch per query)...

    You could also look into using a 2nd level cache to avoid unnecessary fetching...

  8. #8
    Join Date
    Aug 2004
    Posts
    203

    Default

    What I can do if my collection have > 10000 rows , for instance, I have Customer class and
    customer Orders - one customer have 10000 rows - hibernate load all rows in memory and it is unusable for me = I want pure cursor behavior and only < fetchSize rows in memory

    regards

  9. #9
    Join Date
    Sep 2004
    Location
    Melbourne, Australia
    Posts
    54

    Default

    You could look into using filters on your collections... I've played around with them in Hibernate 2 a bit, they are pretty basic but works. Hibernate 3 has much cooler filtering...

    Until Hibernate 3 gets going I think you'll be faced with changing your design a little to compensate for the fact that you have large collections.

    nb: that should have been n+1 above...

  10. #10
    Join Date
    Aug 2004
    Posts
    203

    Default

    Hello,
    I don't want filtering.I want show all rows (size) to user but only a few in memory - user can walk, sort search rows, but in memory is only < xxx rows in one moment

    I want specify rows in memory in ocllection , for instance

    <set name="example" rows="100" ... />

    and I know now that I have only <= 100 rows in memory, but example.size return correct number of rows, get(10000) work etc

    I do it with hibernate Scrollable resultset except one-to-many ampping, but it be cool that hibernate do it

    Database cursors work this fine

    regards

Similar Threads

  1. EJB Transaction and Spring/Hibernate
    By etienno in forum Data
    Replies: 5
    Last Post: Aug 26th, 2005, 12:26 AM
  2. New Book: Mastering Spring from PHEI of China
    By worldheart in forum Announcements
    Replies: 2
    Last Post: May 22nd, 2005, 09:21 PM
  3. Any tech progress since Rod's One-on-One w/o EJB book?
    By Chuck Zheng in forum Architecture
    Replies: 2
    Last Post: Mar 14th, 2005, 05:42 AM
  4. New Book: Spring in Action from Manning
    By helent in forum Announcements
    Replies: 0
    Last Post: Feb 23rd, 2005, 02:41 PM
  5. The new book in Germany
    By j2ux in forum Meta
    Replies: 12
    Last Post: Sep 10th, 2004, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •