use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
private Object newReverseEngineeringStrategy(final String className, Object delegate) {
try {
Class<?> clazz = ReflectHelper.classForName(className);
Class<?> revEngClass = ReflectHelper.classForName("org.hibernate.cfg.reveng.ReverseEngineeringStrategy");
Constructor<?> constructor = clazz.getConstructor(new Class[] { revEngClass });
return constructor.newInstance(new Object[] { delegate });
} catch (NoSuchMethodException e) {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Class<?> clazz = null;
if (contextClassLoader != null) {
clazz = contextClassLoader.loadClass(className);
} else {
clazz = Class.forName(className);
}
if (clazz != null) {
return clazz.newInstance();
} else {
throw new HibernateException("Class " + className + " could not be found.");
}
} catch (Exception eq) {
throw new HibernateException(eq);
}
} catch (Exception e) {
throw new HibernateException(e);
}
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newDialect.
@Override
public String newDialect(Properties properties, final Connection connection) {
ServiceRegistry serviceRegistry = buildServiceRegistry(properties);
DialectFactory dialectFactory = serviceRegistry.getService(DialectFactory.class);
Dialect dialect = dialectFactory.buildDialect(properties, new DialectResolutionInfoSource() {
@Override
public DialectResolutionInfo getDialectResolutionInfo() {
try {
return new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData());
} catch (SQLException sqlException) {
throw new HibernateException("Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", sqlException);
}
}
});
return dialect != null ? dialect.toString() : null;
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
private Object newReverseEngineeringStrategy(final String className, Object delegate) {
try {
Class<?> clazz = ReflectHelper.classForName(className);
Class<?> revEngClass = ReflectHelper.classForName("org.hibernate.cfg.reveng.ReverseEngineeringStrategy");
Constructor<?> constructor = clazz.getConstructor(new Class[] { revEngClass });
return constructor.newInstance(new Object[] { delegate });
} catch (NoSuchMethodException e) {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Class<?> clazz = null;
if (contextClassLoader != null) {
clazz = contextClassLoader.loadClass(className);
} else {
clazz = Class.forName(className);
}
if (clazz != null) {
return clazz.newInstance();
} else {
throw new HibernateException("Class " + className + " could not be found.");
}
} catch (Exception eq) {
throw new HibernateException(eq);
}
} catch (Exception e) {
throw new HibernateException(e);
}
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newDialect.
@Override
public String newDialect(Properties properties, final Connection connection) {
ServiceRegistry serviceRegistry = buildServiceRegistry(properties);
DialectFactory dialectFactory = serviceRegistry.getService(DialectFactory.class);
Dialect dialect = dialectFactory.buildDialect(properties, new DialectResolutionInfoSource() {
@Override
public DialectResolutionInfo getDialectResolutionInfo() {
try {
return new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData());
} catch (SQLException sqlException) {
throw new HibernateException("Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", sqlException);
}
}
});
return dialect != null ? dialect.toString() : null;
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class SchemaExportFacadeTest method testGetExceptions.
@SuppressWarnings("unchecked")
@Test
public void testGetExceptions() throws Throwable {
String urlString = "jdbc:h2:mem:create_test";
configuration.setProperty(Environment.URL, urlString);
SchemaExport schemaExport = new SchemaExport(configuration);
ISchemaExport schemaExportFacade = FACADE_FACTORY.createSchemaExport(schemaExport);
assertTrue(schemaExportFacade.getExceptions().isEmpty());
schemaExport.getExceptions().add(new HibernateException("blah"));
assertFalse(schemaExportFacade.getExceptions().isEmpty());
}
Aggregations