-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Startup problems with static instances of Persistent objects
PostPosted: Thu Sep 25, 2003 10:12 am 
Newbie

Joined: Tue Aug 26, 2003 10:39 pm
Posts: 2
Location: Iowa City, IA
We have a system where we make use of the HibernateSession and PersistentRootClass patterns. We have a number of Enum type of objects that we initialize from the database, but we are facing a recursion problem during startup.

Here is an example of one of the Enum classes

Code:
public final class EnumType extends PersistentEnum implements Serializable, Comparable
{
   public static final EnumType FOO1= EnumType.findByOID( 1 );
   public static final EnumType FOO2= EnumType.findByOID( 2 );
   public static final EnumType FOO3= EnumType.findByOID( 3 );
   ...


We create static instances of these enums so that we can grab handles to them easily, but the problem is that when the app starts up, we call a HibernateSession.startup() method which goes out and creates a new Configuration object, and bootstraps Hibernate. During that bootstrap process, hibernate goes and loads the mapped classes (EnumType), which then during class init tries to create these final static instances - but the problem is that the Hibernate startup process hasn't finished yet, so my HibernateSession class which is used inside the findByOID() method is not yet initialized when it is called to load these static class vars (so it tries to recofigure hibernate...)

I know there are different approaches I can take here to resolve this, but was wondering if anyone else had faced this problem and if they came up with a solution that worked well for them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.