Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Hibernate Configuration and SessionFactory startup time

    11 answers - 1844 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi everyone
    A little background: I'm working on my first Tapestry app. I've been
    involved with Java since 1.0, and involved with software dev for a lot
    longer.
    I'm using Hibernate for db access, having had much joy with it on
    previous projects. The Hibernate Configuration and SessionFactory take
    quite a while to start up. I've stashed the SessionFactory in a
    subclassed Global object, and I'm doing Session disconnect/reconnect in
    a subclassed Engine object. So far so good.
    I have Tomcat configured via server.xml up to use my dev directory as a
    webapp. Which has worked well for previous non-Tapestry apps.
    Here's the problem: in order to get changes to the Java files showing up
    via Tomcat, I need to enable reloading in Tomcat. But then every time
    a .class file in the classes subdir changes, the app reloads. Which is
    fine except for the long Hibernate startup time.
    I've tried stashing the SessionFactory in another servlet, but that also
    gets reloaded.
    course I already have , and
    that's working nicely for the pages themselves.
    The other option I thought of was to stash the SessionFactory in JNDI.
    That has it's own drawbacks though, not least being the need to set up a
    JNDI provider, and the fact that since I'm already cramming Tapestry
    into my overloaded brain I'd prefer to avoid cramming yet another API in
    as well.
    So I'd really appreciate any suggestions how Hibernate can be used
    without suffering the long startup time each time a .class file changes
    thanks
    John
    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.1 | | 775 bytes | |

    John Anderson <ardour <atsemiosix.comwrites:

    Here's the problem: in order to get changes to the Java files showing up
    via Tomcat, I need to enable reloading in Tomcat. But then every time
    a .class file in the classes subdir changes, the app reloads. Which is
    fine except for the long Hibernate startup time.

    Are you saying that the Hibernate Configuration is loaded
    again whenever your app is reloaded or whenever your app
    is run? If it's the former and you don't mind the latter,
    you can create the Configuration on-demand in your Global.

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.2 | | 1197 bytes | |

    Wed, 2005-05-04 at 01:41 +0000, Kent Tong wrote:
    John Anderson <ardour <atsemiosix.comwrites:

    Here's the problem: in order to get changes to the Java files showing up
    via Tomcat, I need to enable reloading in Tomcat. But then every time
    a .class file in the classes subdir changes, the app reloads. Which is
    fine except for the long Hibernate startup time.

    Are you saying that the Hibernate Configuration is loaded
    again whenever your app is reloaded or whenever your app
    is run?

    Whenever the app is reloaded, which is as often as the .class files
    change in the classes directory.

    What I don't like is that every time I change something in the .java
    files for the project, I have to wait 8-15 seconds for the restart to
    happen. Which adds up to lots of what when it's part of the
    change/compile/reload cycle.

    What exactly do you mean by "whenever your app is run"? Whenever a page
    request hits the server?

    bye
    John

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.3 | | 729 bytes | |

    John Anderson <ardour <atsemiosix.comwrites:

    What I don't like is that every time I change something in the .java
    files for the project, I have to wait 8-15 seconds for the restart to
    happen. Which adds up to lots of what when it's part of the
    change/compile/reload cycle.

    What exactly do you mean by "whenever your app is run"? Whenever a page
    request hits the server?

    Yes. Just create the Configuration in the constructor
    of your Global class. It will be created on the first
    http request.

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.4 | | 951 bytes | |

    Thu, 2005-05-05 at 01:01 +0000, Kent Tong wrote:
    John Anderson <ardour <atsemiosix.comwrites:

    What I don't like is that every time I change something in the .java
    files for the project, I have to wait 8-15 seconds for the restart to
    happen. Which adds up to lots of what when it's part of the
    change/compile/reload cycle.

    What exactly do you mean by "whenever your app is run"? Whenever a page
    request hits the server?

    Yes. Just create the Configuration in the constructor
    of your Global class. It will be created on the first
    http request.

    Thanks for your suggestion. I tried that, but the Global class seems to
    be destroyed every time one of the .class files in the app changes.

    bye
    John

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.5 | | 462 bytes | |

    John Anderson <ardour <atsemiosix.comwrites:

    Thanks for your suggestion. I tried that, but the Global class seems to
    be destroyed every time one of the .class files in the app changes.

    But it will not be recreated until an http request hits your app again.

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.6 | | 681 bytes | |

    Thu, 2005-05-05 at 08:11 +0000, Kent Tong wrote:
    John Anderson <ardour <atsemiosix.comwrites:

    Thanks for your suggestion. I tried that, but the Global class seems to
    be destroyed every time one of the .class files in the app changes.

    But it will not be recreated until an http request hits your app again.

    Exactly. But usually after one has made a change to a .class file, one
    wants to see that the change did what one expected it to, not so?

    bye
    John

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.7 | | 603 bytes | |

    John Anderson <ardour <atsemiosix.comwrites:

    Exactly. But usually after one has made a change to a .class file, one
    wants to see that the change did what one expected it to, not so?

    It only takes a couple of seconds to configure the Configuration
    object for each test run. How does it bother you? If it is taking
    a lot of time, are you using logging? This will slow it down
    significantly.

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.8 | | 1060 bytes | |

    Just use JNDI. JBoss 3.2.7 supports Hibernate in native form making
    this configuration easier. You just have to build the .har file,
    DS, JBoss understands those files with no extra effort.

    JAVIER SANCHEZ

    5/6/05, Kent Tong <kent (AT) cpttm (DOT) org.mowrote:
    John Anderson <ardour <atsemiosix.comwrites:

    Exactly. But usually after one has made a change to a .class file, one
    wants to see that the change did what one expected it to, not so?

    It only takes a couple of seconds to configure the Configuration
    object for each test run. How does it bother you? If it is taking
    a lot of time, are you using logging? This will slow it down
    significantly.

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.9 | | 812 bytes | |

    Fri, 2005-05-06 at 16:46 -0500, Javier Sanchez wrote:
    Just use JNDI. JBoss 3.2.7 supports Hibernate in native form making
    this configuration easier. You just have to build the .har file,
    DS, JBoss understands those files with no extra effort.

    The configuration itself is fine. What I'm not happy with is the
    constant recreating of the SessionFactory.

    Is it possible to serialize a SessionFactory instance in JNDI? If so is
    there a fairly lightweight JNDI provider I can use? I don't want to use
    up 400M of memory running JBoss when I'm going to use only JNDI.

    thanks
    John

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.10 | | 1344 bytes | |

    Fri, 2005-05-06 at 10:27 +0000, Kent Tong wrote:
    John Anderson <ardour <atsemiosix.comwrites:

    Exactly. But usually after one has made a change to a .class file, one
    wants to see that the change did what one expected it to, not so?

    It only takes a couple of seconds to configure the Configuration
    object for each test run. How does it bother you?

    10-20 seconds to reload the app, of which Hibernate is usually 5 - 8.
    Which doesn't seem like much, except when you do a change that takes 20
    or 30 seconds, and you do an hour of that, you spend 15-20 minutes of
    that hour waiting for app reloads.

    And regardless of the numbers, it got to the point where that startup
    time of the app was annoying.

    If it is taking a lot of time, are you using logging? This will slow
    it down significantly.

    Exactly. I'm only allowing log4j to show Hibernate warnings, so I can
    see if something goes wrong. The reams and reams of debug logging is
    turned off. An app restart generates about 10 lines of logging, which I
    don't think is going to cause much of a slowdown.

    bye
    John

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
  • No.11 | | 593 bytes | |

    John Anderson <ardour <atsemiosix.comwrites:

    10-20 seconds to reload the app, of which Hibernate is usually 5 - 8.
    Which doesn't seem like much, except when you do a change that takes 20
    or 30 seconds, and you do an hour of that, you spend 15-20 minutes of
    that hour waiting for app reloads.

    How many persistent classes do you have? Have you tried the
    serialization tip ()?

    To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org

Re: Hibernate Configuration and SessionFactory startup time


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Java"

EMSDN.COM