use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class IndividuallySchemaValidatorImplTest method testMissingEntityContainsUnqualifiedEntityName.
@Test
public void testMissingEntityContainsUnqualifiedEntityName() throws Exception {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(UnqualifiedMissingEntity.class);
final MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
metadata.validate();
try {
getSchemaValidator(metadata);
Assert.fail("SchemaManagementException expected");
} catch (SchemaManagementException e) {
assertEquals("Schema-validation: missing table [UnqualifiedMissingEntity]", e.getMessage());
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SchemaUpdate method buildMetadata.
private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, ServiceRegistry serviceRegistry) throws Exception {
final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
for (String filename : parsedArgs.hbmXmlFiles) {
metadataSources.addFile(filename);
}
for (String filename : parsedArgs.jarFiles) {
metadataSources.addJar(new File(filename));
}
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
final StrategySelector strategySelector = serviceRegistry.getService(StrategySelector.class);
if (parsedArgs.implicitNamingStrategyImplName != null) {
metadataBuilder.applyImplicitNamingStrategy(strategySelector.resolveStrategy(ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategyImplName));
}
if (parsedArgs.physicalNamingStrategyImplName != null) {
metadataBuilder.applyPhysicalNamingStrategy(strategySelector.resolveStrategy(PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategyImplName));
}
return (MetadataImplementor) metadataBuilder.build();
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SchemaUpdate method main.
public static void main(String[] args) {
try {
final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs(args);
final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry(parsedArgs);
try {
final MetadataImplementor metadata = buildMetadata(parsedArgs, serviceRegistry);
new SchemaUpdate().setOutputFile(parsedArgs.outputFile).setDelimiter(parsedArgs.delimiter).execute(parsedArgs.targetTypes, metadata, serviceRegistry);
} finally {
StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
} catch (Exception e) {
LOG.unableToRunSchemaUpdate(e);
e.printStackTrace();
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SchemaUpdateTask method execute.
/**
* Execute the task
*/
@Override
public void execute() throws BuildException {
log("Running Hibernate Core SchemaUpdate.");
log("This is an Ant task supporting only mapping files, if you want to use annotations see http://tools.hibernate.org.");
try {
final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder();
configure(ssrBuilder);
final StandardServiceRegistry ssr = ssrBuilder.build();
final MetadataSources metadataSources = new MetadataSources(ssr);
configure(metadataSources);
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
configure(metadataBuilder, ssr);
final MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build();
new SchemaUpdate().setOutputFile(outputFile.getPath()).setDelimiter(delimiter).setHaltOnError(haltOnError).execute(TargetTypeHelper.parseLegacyCommandLineOptions(!quiet, !text, outputFile.getPath()), metadata);
} catch (HibernateException e) {
throw new BuildException("Schema text failed: " + e.getMessage(), e);
} catch (FileNotFoundException e) {
throw new BuildException("File not found: " + e.getMessage(), e);
} catch (IOException e) {
throw new BuildException("IOException : " + e.getMessage(), e);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(e);
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SchemaValidator method main.
public static void main(String[] args) {
try {
final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs(args);
final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry(parsedArgs);
try {
final MetadataImplementor metadata = buildMetadata(parsedArgs, serviceRegistry);
new SchemaValidator().validate(metadata, serviceRegistry);
} finally {
StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
} catch (Exception e) {
LOG.unableToRunSchemaUpdate(e);
e.printStackTrace();
}
}
Aggregations