I am trying to upgrade a webapp from Hibernate 4.2.6 to 5.2.5 and I am having problems validating the schema - it always fails claiming that the first table (in alphabetical order) is missing.
If I disable schema validation, I can create the SessionFactory and I can read the table that schema validation claims it cannot find.
This table is defined as follows:
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class AbstractBackgroundTask extends BaseManagedObject implements ProgressListener, GetNameInterface
My code to create the SessionFactory is below:
Code:
private void doHibCfg(Configuration cfg)
{
String dbUrl = cfg.getProperty(Environment.URL);
LOG.info("Using JDBC URL " + dbUrl);
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().configure("hibernate.cfg.xml");
builder.applySettings(cfg.getProperties());
StandardServiceRegistry registry = builder.build();
sessionFactory = cfg.buildSessionFactory(registry);
// Also tried the following line
// sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
LOG.info("SessionFactory created...");
}
Below is some logging I enabled and the stack trace (I've anonymized the URL and the package name of my class).
Appreciate any help or suggestions...
Quote:
2016-12-12 18:16:11,432 INFO: HHH000412: Hibernate Core {5.2.5.Final} [Version[main]]
2016-12-12 18:16:11,442 INFO: HHH000206: hibernate.properties not found [Environment[main]]
2016-12-12 18:16:12,003 INFO: API - Using JDBC URL jdbc:sqlserver://XXX.lab.local;databaseName=YYY;lockTimeout=20000;loginTimeout=10 [TxFactory[main]]
2016-12-12 18:16:12,043 TRACE: trying via [new URL("hibernate.cfg.xml")] [ClassLoaderServiceImpl[main]]
2016-12-12 18:16:12,043 TRACE: trying via [ClassLoader.getResourceAsStream("hibernate.cfg.xml")] [ClassLoaderServiceImpl[main]]
2016-12-12 18:16:12,133 INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} [Version[main]]
2016-12-12 18:16:12,243 INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.c3p0.internal.C3P0ConnectionProvider [ConnectionProviderInitiator[main]]
2016-12-12 18:16:12,253 INFO: HHH010002: C3P0 using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://XXX.lab.local;databaseName=YYY;lockTimeout=20000;loginTimeout=10 [C3P0ConnectionProvider[main]]
2016-12-12 18:16:12,253 INFO: HHH10001001: Connection properties: {user=sa, password=****} [C3P0ConnectionProvider[main]]
2016-12-12 18:16:12,253 INFO: HHH10001003: Autocommit mode: false [C3P0ConnectionProvider[main]]
2016-12-12 18:16:12,435 INFO: HHH10001007: JDBC isolation level: <unknown> [C3P0ConnectionProvider[main]]
2016-12-12 18:16:12,545 INFO: HHH000400: Using dialect: com.zzz.mgmt.util.ExtendedLegacySqlServerDialect [Dialect[main]]
2016-12-12 18:16:12,676 INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException [LobCreatorBuilderImpl[main]]
2016-12-12 18:16:12,766 DEBUG: Created database namespace [logicalName=Name{catalog=null, schema=null}, physicalName=Name{catalog=null, schema=null}] [Namespace[main]]
2016-12-12 18:16:13,526 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:13,536 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:13,536 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:13,546 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:13,546 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:13,546 INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect [Dialect[main]]
2016-12-12 18:16:14,986 INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@575cabf0] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. [access[main]]
2016-12-12 18:16:15,156 ERROR: API - Error (v5.8.7.pre-161206-17-24571) [TestPeD[main]]
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [AbstractBackgroundTask]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at com.zzz.mgmt.api.TxFactory.doHibCfg(TxFactory.java:609)