Issue
Whenever I run my hibernate 5, I see this error:
ERROR: Could not fetch the SequenceInformation from the database
com.microsoft.sqlserver.jdbc.SQLServerException: The "variant" data type is not supported.
I've never heard of a "variant" data type before. Or is it a category of data types? Not sure.
I checked the data types in all my tables, and these are the ones that are there: bigint, bit, date, datetime, int, numeric, varbinary, and varchar.
Where could this error be coming from? Is there somewhere else I should check for variant types?
EDIT:
I ran this query select distinct data_type from INFORMATION_SCHEMA.COLUMNS
to get all the data types in my database, and sql variant didn't show up. That's how I'm sure there isn't one.
Is there somewhere else this could be referenced?
EDIT 2:
A little bit more information on this. The application is a maven project. I created a normal java project and ran the same codes against the same database, and I didn't get any error about sql variant types.
So this issue seems to be tied to the hibernate dependency. I don't get it, really. This is the dependency I'm using:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
Solution
Alright. So, I checked the library I was using in my normal java application, and it's Hibernate 5.3.7. The one I'm using in my maven application is 5.4.0.
So I changed the hibernate library in my maven app to:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.7.Final</version>
</dependency>
And now everything works. No complaints about some weird some weird Sql Variant type.
This issue also affects Hibernate search 5.11.0. You should use 5.10.5.Final.
Unfortunately, I don't have the proper credentials to raise this with the hibernate team on their issues tracker. Hopefully one of them will come across this post and address it. I know they're working on a hibernate search 6 and hibernate ORM 6, so that's good news!
Answered By - Akin_Glen
Answer Checked By - Pedro (JavaFixing Volunteer)