java.lang.ClassCastException: java.math.cannot be cast to java.lang.Long while starting server

In my opinion that is a bug in Hibernate (see also https://hibernate.atlassian.net/browse/HHH-13805 and https://discourse.hibernate.org/t/sql-server-could-not-fetch-the-sequenceinformation-from-the-database/4083). In SQL Server sequences are typed that is they can be int, smallint, long, … That is reflected in the meta data returned by the INFORMATION_SCHEMA.SEQUENCES view. However, Hibernate assumes that the schema columns holding the min, max and current values for the sequence are always of type long. That is not the case. They are holding and returning values of the type of the defined sequence. I recently had to work around that problem and wrote my own custom dialect with a custom implementation of the SequenceInformationExtractorLegacyImpl class that deals with the multiple types.

1 Like