-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Cannot validate schema after upgrading to 5.2.5
PostPosted: Mon Dec 12, 2016 7:39 pm 
Newbie

Joined: Fri Dec 09, 2016 5:27 pm
Posts: 8
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)


Top
 Profile  
 
 Post subject: Re: Cannot validate schema after upgrading to 5.2.6
PostPosted: Tue Dec 13, 2016 4:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
According to your mapping, a JOINED inheritance model should have a base class table, which in your case is AbstractBackgroundTask.

Do you have the AbstractBackgroundTask table in your DB schema?


Top
 Profile  
 
 Post subject: Re: Cannot validate schema after upgrading to 5.2.6
PostPosted: Tue Dec 13, 2016 8:48 am 
Newbie

Joined: Fri Dec 09, 2016 5:27 pm
Posts: 8
Yes - that base table exists in the database.
This webapp has been working with Hibernate 4.2.6 for a long time. And, as I said, I was able to read that table through Hibernate when I disabled schema validation under 5.2.5.


Top
 Profile  
 
 Post subject: Re: Cannot validate schema after upgrading to 5.2.6
PostPosted: Tue Dec 13, 2016 9:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Hibernate 5 made a lot of changes in regards to schema mapping. Try coming up with a a replicating test case, and then open a new Jira issue for this.

You could also dig a little bit into it and send us a Pull Request. This way, you'll make sure that the fix is applied in the next release, which is 5.2.6.


Top
 Profile  
 
 Post subject: Re: Cannot validate schema after upgrading to 5.2.6
PostPosted: Tue Dec 13, 2016 1:18 pm 
Newbie

Joined: Fri Dec 09, 2016 5:27 pm
Posts: 8
Found my initial problem - I needed to add the default schema name to hibernate.cfg.xml.
Quote:
<property name="hibernate.default_schema">dbo</property>


Now schema validation is failing on one of my join tables defined as:
Quote:
@ElementCollection
@CollectionTable(name="MigrateUserBackupsTask_backupFoldernames",
joinColumns=@JoinColumn(name="MigrateUserBackupsTask_TASK_ID"))
@Column(columnDefinition = "nvarchar(255)", name = "element")
private List<String> backupFolderNames = null;


I have other join tables that are defined using the same 3 annotations - they all validate, but this one does not. I'll dig more into this and post anything I find.


Top
 Profile  
 
 Post subject: Re: Cannot validate schema after upgrading to 5.2.5
PostPosted: Tue Dec 13, 2016 3:59 pm 
Newbie

Joined: Fri Dec 09, 2016 5:27 pm
Posts: 8
It appears that the schema validation does not like the length of the table name - MigrateUserBackupsTask_backupFoldernames.
When I shortened it to MigrateUserBackupsTask_bfn the schema validation worked.

What doesn't make sense to me is that I have another join table - ActivityCenterPolicy_defaultNetworkTypes.
That also has 40 characters - but that table validates without having to shorten the name.

I'll post more if I find anything else on this topic.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.