Issue Type: Bug Bug
Affects Versions: 4.1.4
Assignee: Unassigned
Created: 21/Aug/12 3:46 AM
Description:

While developping, we had some table names generated by the naming strategy more than 64 chars.

However, PostGRESQL truncate by default everything over the 63rd character.

During the validation process of Hibernate (we have turned on <entry key="hibernate.hbm2ddl.auto" value="validate" /> in our spring configuration), the hibernate failed to validate because it's trying to match the long name (more than > 64chars) with the trunacted one.

Here is an example of the stacktrace we have at the start of our application

javax.persistence.PersistenceException: [PersistenceUnit: GHXPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268) ~[spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) ~[spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
... 39 common frames omitted
Caused by: org.hibernate.HibernateException: Missing table: surgery_case_catalog_and_pricing_completion_after_item_list_assignation
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1272) ~[hibernate-core-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155) ~[hibernate-core-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:500) ~[hibernate-core-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744) ~[hibernate-core-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
... 45 common frames omitted

It seems something is wrong with the Dialect, the DatabaseMetadata or the Configuration.validateSchema method.

As if there was a miss in using DatabaseMetadata.maxTableNameLength or something like that.

Environment: hibernate-core-4.1.4.Final.jar, All plateform, PostGRESQL 9.0
Project: Hibernate ORM
Priority: Major Major
Reporter: Martin Braure de Calignon
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira