bytefish / bytefish.de

Resources for building my personal website.
https://www.bytefish.de
MIT License
4 stars 8 forks source link

Thank you for the excellent article. Unfortunately, it did not work for me. #35

Closed vpateleeoc closed 4 years ago

vpateleeoc commented 4 years ago

I followed the article and created my table. However, I got this error while inserting a row in the audit table. Instead of inserting an integer in column "rev", it tried to insert a hashmap.

"ClassCastException: java.util.HashMap cannot be cast to java.lang.Integer"

Some additional information from the log: Hibernate: select nextval ('hibernate_sequence') Hibernate: insert into ims_audit.revinfo (revtstmp, rev) values (?, ?) 2020-02-21 08:31:34 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - [1582291894650] 2020-02-21 08:31:34 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [2] as [INTEGER] - [71] Hibernate: insert into ims_audit.private_charging_party (REVTYPE, REVEND, address_line1, address_line2, cell_number, city, country, county, date_of_birth, email_address, extension, fax_number, first_name, home_phone, is_hispanic, language_code, last_name, mediation_reply, middle_initial, name_prefix, name_suffix, national_origin, organization_name, other_language, position_statement_release_dte, position_statement_request, position_statement_request_dte, race, sex, sign_language_need, state, work_phone, zip_code, charging_party_id, REV) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

The problem is here: binding parameter [27] as [INTEGER] - [{REV=PrepaRevisionEntity [getRevisionDate()=Fri Feb 21 08:31:34 EST 2020, hashCode()=1743932516, toString()=BaseRevisionEntity [revisionNumber=71, revisionTimestamp=1582291894650], getClass()=class gov.eeoc.prepa.ws.modern.entity.common.SampleRevisionEntity], respondentId=66}]

2020-02-21 08:31:34 ERROR org.hibernate.AssertionFailure - HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.Integer

bytefish commented 4 years ago

When browsing the error I saw this stackoverflow post, which I assume is by you. There you have also posted the Annotated Entity. I see there is a property named "originalId". Could you try to rename the property to something else?

Maybe this causes a problem, because it is often used internally by Hibernate Envers:

I have also added a comment to your post on GitHub:

bytefish commented 4 years ago

According to:

The problem was indeed the property named "originalId".