public class EntityMetaData implements SessionFactoryBuilderFactory {
// private static final ThreadLocal<MetadataImplementor> meta = new ThreadLocal<>(); // previously used, but did not work, so used HashMap
private static final Map<String, MetadataImplementor> meta = new HashMap<>();
private static final String METADATAKEY = "M";
@Override
public SessionFactoryBuilder getSessionFactoryBuilder(MetadataImplementor metadata, SessionFactoryBuilderImplementor defaultBuilder) {
// meta.set(metadata);
meta.put(METADATAKEY, metadata);
return defaultBuilder;
}
public static MetadataImplementor getMeta() {
// return meta.get();
return meta.get(METADATAKEY);
}
}
The above code works in tomcat 8 of Local environment, but in tomcat 8 of production environment not working as getMeta()
method returns null.
In Local Environment, getSessionFactoryBuilder
method is called while server is getting started so that it is working in Local, but in Production environment getSessionFactoryBuilder
method not called thus getMeta()
returns null
.
Any help could be appreciated.
Please help me on this.