# Migrate Hibernate3 to Hibernate 5.4.30

**URL:** https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502
**Category:** Hibernate ORM
**Created:** [June 28, 2021, 12:07pm UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502 "2021-06-28T12:07:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [June 28, 2021, 12:07pm UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/1 "2021-06-28T12:07:04Z")

</div>

Can someone share hibernate 3 to Hibernate 5.4.30 migration guide?

---

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [June 28, 2021, 12:09pm UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/2 "2021-06-28T12:09:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [June 30, 2021, 6:30am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/3 "2021-06-30T06:30:26Z")

</div>

Here are all migration guides: [Migration Guides · hibernate/hibernate-orm Wiki · GitHub](https://github.com/hibernate/hibernate-orm/wiki/Migration-Guides)

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.

---

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [July 2, 2021, 6:16am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/4 "2021-07-02T06:16:25Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [July 2, 2021, 6:44am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/5 "2021-07-02T06:44:38Z")

</div>

It’s hard to say, depends on the configuration. Maybe you should configure the database name as “catalog” in your `@Table` annotations.

---

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [July 2, 2021, 7:46am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/6 "2021-07-02T07:46:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [July 2, 2021, 9:07am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/7 "2021-07-02T09:07:12Z")

</div>

Can you provide direct Hibernate 3 to 5 Migration steps document?

---

<div class="post-metadata">

### Author: ![aapathak1221](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aapathak1221](https://discourse.hibernate.org/u/aapathak1221)
#### Post date: [July 2, 2021, 9:10am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/8 "2021-07-02T09:10:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [July 2, 2021, 11:03am UTC](https://discourse.hibernate.org/t/migrate-hibernate3-to-hibernate-5-4-30/5502/9 "2021-07-02T11:03:06Z")

</div>

> 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.
