Search in sources :

Example 6 with HibernateConsoleRuntimeException

use of org.hibernate.console.HibernateConsoleRuntimeException 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 HibernateConsoleRuntimeException(eq);
        }
    } catch (Exception e) {
        throw new HibernateConsoleRuntimeException(e);
    }
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) SQLException(java.sql.SQLException) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException)

Example 7 with HibernateConsoleRuntimeException

use of org.hibernate.console.HibernateConsoleRuntimeException 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 HibernateConsoleRuntimeException("Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", sqlException);
            }
        }
    });
    return dialect != null ? dialect.toString() : null;
}
Also used : DialectResolutionInfoSource(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource) SQLException(java.sql.SQLException) MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) Dialect(org.hibernate.dialect.Dialect) DatabaseMetaDataDialectResolutionInfoAdapter(org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) ServiceRegistry(org.hibernate.service.ServiceRegistry) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) DialectResolutionInfo(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)

Example 8 with HibernateConsoleRuntimeException

use of org.hibernate.console.HibernateConsoleRuntimeException 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 HibernateConsoleRuntimeException("Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", sqlException);
            }
        }
    });
    return dialect != null ? dialect.toString() : null;
}
Also used : DialectResolutionInfoSource(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource) SQLException(java.sql.SQLException) MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) Dialect(org.hibernate.dialect.Dialect) DatabaseMetaDataDialectResolutionInfoAdapter(org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) ServiceRegistry(org.hibernate.service.ServiceRegistry) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) DialectResolutionInfo(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)

Example 9 with HibernateConsoleRuntimeException

use of org.hibernate.console.HibernateConsoleRuntimeException 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 HibernateConsoleRuntimeException(eq);
        }
    } catch (Exception e) {
        throw new HibernateConsoleRuntimeException(e);
    }
}
Also used : IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) DefaultReverseEngineeringStrategy(org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy) ReverseEngineeringStrategy(org.hibernate.cfg.reveng.ReverseEngineeringStrategy) PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException)

Example 10 with HibernateConsoleRuntimeException

use of org.hibernate.console.HibernateConsoleRuntimeException 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 HibernateConsoleRuntimeException("Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use", sqlException);
            }
        }
    });
    return dialect != null ? dialect.toString() : null;
}
Also used : DialectResolutionInfoSource(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource) SQLException(java.sql.SQLException) MetaDataDialect(org.hibernate.cfg.reveng.dialect.MetaDataDialect) Dialect(org.hibernate.dialect.Dialect) DatabaseMetaDataDialectResolutionInfoAdapter(org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) ServiceRegistry(org.hibernate.service.ServiceRegistry) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) DialectResolutionInfo(org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)

Aggregations

HibernateConsoleRuntimeException (org.hibernate.console.HibernateConsoleRuntimeException)34 SQLException (java.sql.SQLException)10 File (java.io.File)8 CoreException (org.eclipse.core.runtime.CoreException)7 PersistentClass (org.hibernate.mapping.PersistentClass)7 RootClass (org.hibernate.mapping.RootClass)7 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)7 Properties (java.util.Properties)5 MetaDataDialect (org.hibernate.cfg.reveng.dialect.MetaDataDialect)5 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)5 Dialect (org.hibernate.dialect.Dialect)5 DatabaseMetaDataDialectResolutionInfoAdapter (org.hibernate.engine.jdbc.dialect.spi.DatabaseMetaDataDialectResolutionInfoAdapter)5 DialectFactory (org.hibernate.engine.jdbc.dialect.spi.DialectFactory)5 DialectResolutionInfo (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo)5 DialectResolutionInfoSource (org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource)5 ServiceRegistry (org.hibernate.service.ServiceRegistry)5 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)5 IOException (java.io.IOException)4 Configuration (org.hibernate.cfg.Configuration)3 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)3