Transform between hibernate entity name with jpa entity name

Description

Hibernate use qualified class name as entity's name. However JPA use unqualified class name as entity's name. Before version 5.2, I can transform them by entity class. From version 5.2, class meta data is deprecated in hibernate, we can only get jpa's meta model which using unqualified class name by public api. However, other hibernate module and hibernate core internal still use old qualified entity name. We are unable to get this qualified entity name from hibernate public api now. But with other hibernate module, we still need them. We need a api to transform the jpa entity name to hibernate entity name.

Environment

None

Activity

Show:
Chris Cranford
January 25, 2018, 3:45 PM

That information is still there, its just available through a SPI now rather than necessarily a public API

Xj Chen
January 25, 2018, 3:55 PM

Is there a solution without getMetamodel´╝č getMetamodel does not exist in version 5.1.x. I need a method to get this information compatible with both version 5.1 and 5.2

Chris Cranford
January 25, 2018, 4:31 PM

A slight variant to my prior answer, as this code exists on both releases as-is:

While this method is deprecated in 5.2, it does exist in 5.1 allowing you to use a single code path without any reflection.
As a heads up, I would expect these deprecated methods being removed in 6.0.

Xj Chen
January 31, 2018, 6:57 PM

In the end I decided to use reflections. By the way, will caching related method objects with static fields result in memory leaks?

Assignee

Unassigned

Reporter

Xj Chen

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure