Can someone share hibernate 3 to Hibernate 5.4.30 migration guide?
In my persistence.xml file, multiple persistent units are present.
When I execute simple select query, Hibernate searches table in other schema and run time throw SQL grammar exception, Table doesn’t exist.
Here are all migration guides: Migration Guides · hibernate/hibernate-orm Wiki · GitHub
If you have specific issues, please create a new topic and explain what you are doing exactly as well as share stack traces of the exceptions you are facing.
Thank you for your reply.
Actual Issue,
Multiple database schemas in my application. I have created object of Entity Manager Factory for all schemas.
Lets consider below schema,
Database1 → Table1, Table2, Table3
Database2 → Table4, Table5, Table6
When I get data from Table1 of Database 1 using Database1 EntityManager, It internally throw Error “Database1.Table4” does not exist. But here Table 4 is part of Database2. Why it is looking in database1?
It’s hard to say, depends on the configuration. Maybe you should configure the database name as “catalog” in your @Table
annotations.
I am not declear schema name in entity in @Table annotation.
I have multiple Database.cfg.xml file and here I specified MySql Connection URL.
Can you provide direct Hibernate 3 to 5 Migration steps document?
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: database1] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1336)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1262)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at com.server.metadb.PersistenceFactory.init(PersistenceFactory.java:514)
at com.server.metadb.PersistenceFactory.(PersistenceFactory.java:119)
… 48 more
Caused by: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:112)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:181)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:303)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259)
… 53 more
Caused by: org.hibernate.AssertionFailure: Table database1.table4 not found
at org.hibernate.persister.entity.AbstractEntityPersister.getTableId(AbstractEntityPersister.java:5687)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.(JoinedSubclassEntityPersister.java:449)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
… 58 more
I am not declear schema name in entity in @Table annotation.
I have multiple Database.cfg.xml file and here I specified MySql Connection URL.
If you have multiple configurations you will have to list the fully qualified names of the entities that map to the respective tables of a database in that configuration file i.e. in the db1 config file, add entities for tables that belong to that and the others should be listed in the db2 config file. Otherwise Hibernate will pick up entities that shouldn’t be picked up for a certain persistence unit like it might be the case for you.
Can you provide direct Hibernate 3 to 5 Migration steps document?
I can not provide you that as such a document does not exist. Like I wrote, you will have to go through all the migration steps one by one for every update.
Without seeing the entity model and the configurations I can’t help you further. Apparently a table within a joined hierarchy can’t be found with a certain default schema name.