Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 952284 - Hibernate SchemaValidation on synonyms
Hibernate SchemaValidation on synonyms
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
TBD EAP 6
Unspecified Unspecified
unspecified Severity unspecified
: ER1
: EAP 6.2.0
Assigned To: Brett Meyer
:
Depends On:
Blocks: eap62-upgrade-hibernate425
  Show dependency treegraph
 
Reported: 2013-04-15 10:50 EDT by Adam Kovari
Modified: 2015-09-01 00:00 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
JBoss EAP 6 has been enhanced by providing the ability for Hibernate entities to be validated against table synonyms. Previously, the schema validation would only validate tables and views. To enable this new functionality, the `hibernate.synonyms=true` property must be set. For example, the following will now pass Hibernate schema validation: ---- "CREATE SYNONYM foo_synonym FOR foo_table" @Table(name = "foo_synonym") ----
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-12-15 11:12:56 EST
Type: Enhancement
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBPAPP-10707 Minor Resolved EAP 5.1.1 - One off patch for BZ-952284 - Hibernate SchemaValidation on synonyms 2017-07-25 18:39 EDT
JBoss Issue Tracker JBPAPP-10709 Minor Closed Hibernate SchemaValidation on synonyms 2017-07-25 18:39 EDT

  None (edit)
Description Adam Kovari 2013-04-15 10:50:21 EDT
Description of problem:
With "hibernate.hbm2ddl.auto=validate",

if there are synonyms on DB tables, the validation fails.
Sure, the schema validation could be disabled, but this validation gives a developer a better "security" feeling.

Upstream Jira/Patch:
https://hibernate.atlassian.net/browse/HHH-8183


Version-Release number of selected component (if applicable):
All up to EAP 6.1.0 Alpha


How reproducible:
Always

Steps to Reproduce:
1. use synonym on a table name
2. deploy an application with hbm2ddl = auto
  
Actual results:
Validation error.

Expected results:
Validation pass.

Additional info:
Pull requests:
* for master : https://github.com/hibernate/hibernate-orm/pull/508
* for 3.3 branch : https://github.com/hibernate/hibernate-orm/pull/510
Comment 1 Brett Meyer 2013-04-15 13:28:47 EDT
Adam, is this for a one-off, or just the permanent fix in 6.2.0?
Comment 2 JBoss JIRA Server 2013-04-15 15:19:01 EDT
Brett Meyer <brmeyer@redhat.com> made a comment on jira JBPAPP-10707

Attaching patched jar
Comment 3 JBoss JIRA Server 2013-04-15 15:34:50 EDT
Brad Maxwell <bmaxwell@redhat.com> made a comment on jira JBPAPP-10707

JBPAPP-10707-signed.tgz contains signed versions of the currently attached jars listed below.

hibernate-core-3.3.2.GA_CP05.jar:
 - MD5 checksum before signing: 272837e01dcdd58b236f8c6b68057cc3
 - MD5 checksum after signing: 8614eb219f0f73583d4f17a4a302861d
Comment 9 Adam Kovari 2013-04-16 02:57:49 EDT
This one is for the permanent fix.
Comment 12 JBoss JIRA Server 2013-04-16 12:24:05 EDT
Brett Meyer <brmeyer@redhat.com> updated the status of jira JBPAPP-10709 to Resolved
Comment 13 JBoss JIRA Server 2013-04-16 12:24:05 EDT
Brett Meyer <brmeyer@redhat.com> made a comment on jira JBPAPP-10709

Committed to http://svn.jboss.org/repos/hibernate/core/branches/Branch_3_3_2_GA_CP/
Comment 20 JBoss JIRA Server 2013-05-03 07:29:17 EDT
Adam Kovari <akovari@redhat.com> made a comment on jira JBPAPP-10709

This doesn't seem to work properly. The table validation succeeds - as it finds the table but it doesn't find any columns. For all columns it reports "Missing column":
{code}
Caused by: org.hibernate.HibernateException: Missing column: id in AKOVARI.TEST_SYN
	at org.hibernate.mapping.Table.validateColumns(Table.java:277)
	at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1131)
	at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:360)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1342)
	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:670)
	... 56 more
{code}

I'll attach a simple reproducer.
Comment 21 JBoss JIRA Server 2013-05-03 07:29:53 EDT
Adam Kovari <akovari@redhat.com> updated the status of jira JBPAPP-10709 to Reopened
Comment 22 JBoss JIRA Server 2013-05-03 07:29:53 EDT
Adam Kovari <akovari@redhat.com> made a comment on jira JBPAPP-10709

Reopening as the column validation seems not to work.
Comment 24 JBoss JIRA Server 2013-05-07 12:05:34 EDT
Brett Meyer <brmeyer@redhat.com> made a comment on jira JBPAPP-10709

Oracle requires that the "includeSynonyms" property be set to "true" in your datasource.  Following up with https://hibernate.atlassian.net/browse/HHH-8226.
Comment 26 JBoss JIRA Server 2013-05-07 16:29:14 EDT
Brett Meyer <brmeyer@redhat.com> made a comment on jira JBPAPP-10709

HHH-8226 committed to http://svn.jboss.org/repos/hibernate/core/branches/Branch_3_3_2_GA_CP/
Comment 27 JBoss JIRA Server 2013-05-07 16:29:25 EDT
Brett Meyer <brmeyer@redhat.com> updated the status of jira JBPAPP-10709 to Resolved
Comment 42 JBoss JIRA Server 2013-06-17 12:24:54 EDT
Christopher O'Brien <cobrien@redhat.com> updated the status of jira JBPAPP-10707 to Resolved
Comment 45 JBoss JIRA Server 2013-06-26 04:32:21 EDT
Adam Kovari <akovari@redhat.com> updated the status of jira JBPAPP-10707 to Resolved
Comment 47 Martin Simka 2013-09-23 09:16:43 EDT
verified on EAP 6.2.0.ER1
Comment 54 JBoss JIRA Server 2014-01-15 19:06:41 EST
Scott Mumford <smumford@redhat.com> updated the status of jira JBPAPP-10709 to Reopened
Comment 55 JBoss JIRA Server 2014-01-15 19:07:55 EST
Scott Mumford <smumford@redhat.com> updated the status of jira JBPAPP-10709 to Closed

Note You need to log in before you can comment on or make changes to this bug.