Revision d1fcc397
Added by Andreas Müller almost 8 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java | ||
---|---|---|
23 | 23 |
import org.hibernate.boot.registry.StandardServiceRegistry; |
24 | 24 |
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; |
25 | 25 |
import org.hibernate.cfg.Configuration; |
26 |
import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl; |
|
27 |
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
|
26 | 28 |
import org.hibernate.mapping.PersistentClass; |
27 | 29 |
import org.hibernate.mapping.Property; |
28 | 30 |
import org.hibernate.metadata.ClassMetadata; |
29 | 31 |
import org.hibernate.property.access.spi.Getter; |
30 | 32 |
import org.osgi.framework.Bundle; |
31 |
|
|
32 | 33 |
import org.hibernate.boot.Metadata; |
33 | 34 |
|
34 | 35 |
|
... | ... | |
79 | 80 |
SessionFactory sessionFactory = null; |
80 | 81 |
Map<String, CdmModelFieldPropertyFromClass> modelClassMap = new HashMap<String, CdmModelFieldPropertyFromClass>(); |
81 | 82 |
try { |
82 |
sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory(); |
|
83 |
Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH); |
|
83 |
// ConnectionProvider connectionProvider = registry.getService(ConnectionProvider.class); |
|
84 |
// DatasourceConnectionProviderImpl providerImpl = registry.getService(DatasourceConnectionProviderImpl.class); |
|
85 |
|
|
86 |
Metadata metadata = new MetadataSources( registry ).buildMetadata(); |
|
87 |
sessionFactory = metadata.buildSessionFactory(); |
|
88 |
// Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH); |
|
84 | 89 |
Map<String, ClassMetadata> classMetaDataMap = sessionFactory.getAllClassMetadata(); |
85 |
Metadata metadata = new MetadataSources( registry ).getMetadataBuilder().applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ).build(); |
|
90 |
// Metadata metadata = new MetadataSources( registry ).getMetadataBuilder().applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ).build();
|
|
86 | 91 |
|
87 | 92 |
|
88 | 93 |
for(ClassMetadata classMetaData :classMetaDataMap.values()) { |
89 |
Class mappedClass = classMetaData.getMappedClass(); |
|
94 |
Class<?> mappedClass = classMetaData.getMappedClass();
|
|
90 | 95 |
|
91 | 96 |
String mappedClassName = mappedClass.getName(); |
92 | 97 |
|
... | ... | |
101 | 106 |
// The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory |
102 | 107 |
// so destroy it manually. |
103 | 108 |
StandardServiceRegistryBuilder.destroy( registry ); |
109 |
e.printStackTrace(); |
|
104 | 110 |
} |
105 | 111 |
|
106 | 112 |
|
Also available in: Unified diff
Preliminary adapt CDM model cacher script to work for cached model update