Replacing HibernateUtil.getConfiguration().getClassMapping in Hibernate 5.x


Ok, been trying to research this issue, and the more I read the more confused I am getting.

I am trying to upgrade an application from Hibernate 4.1 to 5.1 and the getConfiguration().getClassMapping() has been depreciated, and I’m trying to replace it.

Currently, in Hibernate 4.1 this command is working just fine
PersistentClass persistentClass = HibernateUtil.getConfiguration().getClassMapping(CPVForecastHeader.class.getName());

We follow with a series of commands like this:
dbHeaders.put(((Column) persistentClass.getProperty(“mnemonic”).getColumnIterator().next()).getName().trim(), cpvHeader.getMnemonic().trim());

In the log we end up with this (partial results):
13:40:37,656 [main] DEBUG CPVLoader - DB Headers ::: {BADGE=Production Brand, REGNAM=Region, ASYPLT=Production Plant, SRCPLT=Sourc …
Plant, PROGRM=Program, GLBSEG=Global Production Segment, MNFCTR=Manufacturer, CYR01=Jan 2019, CYR02=Feb 2019, NAMPLT=Production Na …
plate, CYR03=Mar 2019, CYR04=Apr 2019, CYR05=May 2019, CYR06=Jun 2019, CYR07=Jul 2019, ASYTYP=Assembly Type, CYR08=Aug 2019, CYR09 …

We use the above result to merge with a similar result from an Excel document that we are loading. The purpose is to map the “DB Headers” the excel column location. This way the users can move the columns on the Excel worksheet into an order that makes the most sense to them, and will not affect the upload process.

Any help would be great.


Check out this answer