Issue
I'm getting the following exception with hibernate:
10:18:14,795 INFO [SchemaValidator] Running schema validator
10:18:14,795 INFO [SchemaValidator] fetching database metadata
10:18:16,958 INFO [DatabaseMetadata] table not found: DUMMY_TABLE
10:18:16,963 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=bkoMdw-ear.ear/bkoMdw-ejb.jar#bkoMdw state=Create
javax.persistence.PersistenceException: [PersistenceUnit: bkoMdw] Unable to build EntityManagerFactory
(...)
Caused by: org.hibernate.HibernateException: Missing table: DUMMY_TABLE
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1127)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:359)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
The problem is that the table exists and the datasource file is correctly configured.
What I'm missing? Any advise to troubleshoot this?
Thanks in advance!
Solution
The problem is that you think the table exists and that the datasource is correctly configured while Hibernate knows that this isn't correct.
Increase the log levels and use -Dhibernate.show_sql=true
to enable logging for SQL statements. That should help to track this one down.
[EDIT] Also make sure you don't have white space before or after a @Table
annotation. If you have this annotation:
@Table(name = "myTable ") // Note the space after the name!!
Then Hibernate will use the quoted name to create the table (so you will have a table with the SQL name 'MYTABLE '
) but it won't always quote the name when you run queries.
Answered By - Aaron Digulla
Answer Checked By - Robin (JavaFixing Admin)