-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unnecesary static code getting excuted through configuration
PostPosted: Fri Feb 03, 2012 3:18 am 
Newbie

Joined: Wed Sep 01, 2010 3:22 am
Posts: 5
We are using hibernate version 3.3.2 we see that there is a piece of code that is unnecessarily put in the code. Please let us know if this is required and ill effects of it. Functionally it is showing no issues but it logs an unnecessary exception.

Class Environment.java ----Inside the static block
try {
InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties"); try {
GLOBAL_PROPERTIES.load(stream);
log.info( "loaded properties from resource hibernate.properties: " + PropertiesHelper.maskOut(GLOBAL_PROPERTIES, PASS) );
}
catch (Exception e) {
log.error("problem loading properties from hibernate.properties");
}
finally {
try{
stream.close();
}
catch (IOException ioe){
log.error("could not close stream on hibernate.properties", ioe);
}
}


Top
 Profile  
 
 Post subject: Re: Unnecesary static code getting excuted through configuration
PostPosted: Fri Feb 03, 2012 3:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
That piece of code is indeed necessary for hibernate users which use the old style approach (not JPA),
these define their properties exactly in hibernate.properties.

If you don't use hibernate.properties as configuration file, then you can simply ignore this logging.
Or if you want to get rid of this logging, you can put an empty file named hibernate.properties in one of the directories
refered by your classpath.


Top
 Profile  
 
 Post subject: Re: Unnecesary static code getting excuted through configuration
PostPosted: Fri Feb 03, 2012 4:53 am 
Newbie

Joined: Wed Sep 01, 2010 3:22 am
Posts: 5
Thank you very much for your help and for a quick response. We will follow the advice


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

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.