I try to migrate from 3.6 to 5.2 but unfortunately I have a problem in SchemaExport, it can not find the ConfigurationService in the registry. Might it be there is a bug in it?
For SchemaExport I need the Metadata, so first I construct it:Code:
URL resource = Hibere.class.getResource("/hibernate.cfg.xml");
Configuration conf = new Configuration().configure(resource);
ConfigurationServiceImpl confService = new ConfigurationServiceImpl(conf.getProperties());
StandardServiceRegistryBuilder builder = conf.getStandardServiceRegistryBuilder();
builder.addService(ConfigurationService.class, confService);
builder.applySettings(conf.getProperties());
Metadata metadata = new MetadataSources(serviceRegistry.build()).buildMetadata();
Then I hand over to SchemaExport:Code:
SchemaExport export = new SchemaExport();
export.setOutputFile("schema.sql");
EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.SCRIPT);
export.execute(targetTypes, Action.BOTH, metadata);
Then I receive following Exception, I check in a debugger and ConfigurationService is found in the Metadata as constructed above however within SchemaExport it is lost:
Code:
org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.engine.config.spi.ConfigurationService]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.tool.hbm2ddl.SchemaExport.buildTargetDescriptor(SchemaExport.java:329)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:247)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:228)