java - Microsoft SQL variant type error pops up when I run hibernate 5
问题描述
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>
解决方案
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!
推荐阅读
- c++ - 在这个 C/C++ 示例中,clang 是否真的以最佳方式添加向量?
- r - 一种使 as.Date 对格式更加谨慎的方法
- java - Java addActionListener,多个实例正在发生
- performance - 为什么 Google Pagespeed Insights 在进行更改后不更新分数?
- kotlin - 无法为递增和递减运算符定义运算符扩展函数
- express - 收到 webhook 时如何渲染视图?
- ios - Spring() 动画完成后 SwiftUI 执行操作
- flutter - 如何在颤振中返回用户流
- html - 如何在 Ruby on Rails HTML 页面中应用 css 样式?
- oracle - 无法从 Kubernetes 内部连接外部 Oracle 数据库