use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newJpaConfiguration.
@Override
public IConfiguration newJpaConfiguration(String entityResolver, String persistenceUnit, Map<Object, Object> overrides) {
getUsageTracker().trackNewConfigurationEvent(HIBERNATE_VERSION);
Ejb3Configuration ejb3Configuration = new Ejb3Configuration();
if (StringHelper.isNotEmpty(entityResolver)) {
try {
Class<?> resolver = ReflectHelper.classForName(entityResolver, this.getClass());
Object object = resolver.newInstance();
ejb3Configuration.setEntityResolver((EntityResolver) object);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new HibernateException(e);
}
}
ejb3Configuration.configure(persistenceUnit, overrides);
Configuration configuration = ejb3Configuration.getHibernateConfiguration();
return facadeFactory.createConfiguration(configuration);
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
@SuppressWarnings("unchecked")
private ReverseEngineeringStrategy newReverseEngineeringStrategy(final String className, ReverseEngineeringStrategy delegate) {
try {
Class<ReverseEngineeringStrategy> clazz = (Class<ReverseEngineeringStrategy>) ReflectHelper.classForName(className);
Constructor<ReverseEngineeringStrategy> constructor = clazz.getConstructor(new Class[] { ReverseEngineeringStrategy.class });
return constructor.newInstance(new Object[] { delegate });
} catch (NoSuchMethodException e) {
try {
Class<?> clazz = ReflectHelper.classForName(className);
ReverseEngineeringStrategy rev = (ReverseEngineeringStrategy) clazz.newInstance();
return rev;
} 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 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 {
Class<?> clazz = ReflectHelper.classForName(className);
return clazz.newInstance();
} 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 ConsoleExtension method hqlCodeComplete.
public CompletionProposalsResult hqlCodeComplete(String query, int startPosition, int currentOffset) {
HQLCompletionHandler handler = new HQLCompletionHandler(startPosition);
if (!hibernateExtension.hasConfiguration()) {
try {
hibernateExtension.build();
hibernateExtension.buildMappings();
} catch (HibernateException e) {
// FIXME
// String mess =
// NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc,
// consoleConfiguration.getName());
// HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
}
}
IHQLCodeAssist hqlEval = hibernateExtension.getHibernateService().newHQLCodeAssist(hibernateExtension.getConfiguration());
query = query.replace('\t', ' ');
hqlEval.codeComplete(query, currentOffset, handler);
return new CompletionProposalsResult(handler.getCompletionProposals(), handler.getLastErrorMessage());
}
use of org.jboss.tools.hibernate.runtime.spi.HibernateException in project jbosstools-hibernate by jbosstools.
the class DTDEntityResolver method getUserResourceAsStream.
private InputStream getUserResourceAsStream(String resource) {
// $NON-NLS-1$
boolean hasLeadingSlash = resource.startsWith("/");
String stripped = hasLeadingSlash ? resource.substring(1) : resource;
InputStream stream = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader != null) {
stream = classLoader.getResourceAsStream(resource);
if (stream == null && hasLeadingSlash) {
stream = classLoader.getResourceAsStream(stripped);
}
}
if (stream == null && service != null) {
stream = service.getClass().getClassLoader().getResourceAsStream(resource);
}
if (stream == null && hasLeadingSlash && service != null) {
stream = service.getClass().getClassLoader().getResourceAsStream(stripped);
}
if (stream == null) {
// $NON-NLS-1$
throw new HibernateException(resource + " not found");
}
return stream;
}
Aggregations