shushu wrote:
Sorry but this is not very helpful, can u publish the class ContextUtils code?
So you are using the Spring Framework as well?! Not only hibernate? This is a class we customized for our needs in the application, it won't help you.
Code:
public class ContextUtils {
private static ClassPathXmlApplicationContext ctx = null;
/**
* Gibt den aktuellen Spring ApplicationContext zurueck. Wird bei bedarf erstellt (Singelton).
*
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
if (ctx == null) {
String[] configLocations = null;
// reading config from properties file springContext.properties
try {
Properties props = new Properties();
InputStream is = ContextUtils.class.getClassLoader().getResourceAsStream("springContext.properties");
props.load(is);
String contextFiles = props.getProperty("contextFiles");
StringTokenizer tok = new StringTokenizer(contextFiles, ",");
configLocations = new String[tok.countTokens()];
for (int idx = 0; tok.hasMoreTokens(); idx++) {
configLocations[idx] = tok.nextToken().trim();
}
}
catch (IOException e) {
e.printStackTrace();
}
ctx = new ClassPathXmlApplicationContext(configLocations);
}
return ctx;
}
}
Did you search the forum for your problem?? You should be able to get the session Factory throught your hibernate configuration. Something like:
Code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
ClassMetadata meta = sessionFactory.getClassMetadata(StakeHolder.class) ;
angela