ClassCastException cannot be cast to java util Map

ClassCastException cannot be cast to java util Map

Hibernate: java.lang.ClassCastException: com.wfs.otc.datamodels.ImagineExpiryModel cannot be cast to java.util.Map

Problem: During working with Hibernate while trying to fetch and map data into Java POJO you get below exception:

Solution: This exception happens if column name return by the store procedure and SQL query is not exactly not matching with the Java model class. In my case Java model attribute name was different than column name return be the store procedure. To fix this issue I had to match Java model name with SQL column name. But it took me little longer to figure this out because exception details from hibernate above is very misleading.

Leave a Reply

Your email address will not be published. Required fields are marked *