Hibernate 是否完全支持 SQLite [英] Does Hibernate Fully Support SQLite

查看:31
本文介绍了Hibernate 是否完全支持 SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jboss Hibernate 没有说明对 SQLite 的支持 -

Jboss Hibernate doesn't say anything about the support for SQLite -

https://community.jboss.org/wiki/SupportedDatabases2

下面同样提到了:

Hibernate+SQLite+Netbeans

能否请您强调一下.我想将嵌入式 SQLite 与休眠一起用于 Swing 桌面应用程序.

Can you please highlight about this. I want to use embedded SQLite with hibernate for swing desktop application.

我也在评估 Derby (JavaDB),因为它也可以嵌入并且是 jdk 的一部分.

I am also evaluating Derby (JavaDB) as it also can be embedded and is part of the jdk.

推荐答案

由于 SQLite 是用于类 C 环境的嵌入式数据库,用 C 编写并因此编译为本机代码,因此 Hibernate(或任何 ORM)将支持的更改不是真的不高Java 是跨平台的,如果有依赖于平台的依赖会有点奇怪.在 Android 上,使用 SQLite,但该平台为其提供了 JDBC 驱动程序.

Since SQLite is an embedded database for C-like environments, written in C and thus compiled to native code, changes that Hibernate (or any ORM) will support aren't really high. Java is cross-platform and it would be a bit weird to have a platform-dependent dependency. On Android, SQLite is used, but there the platform supplies a JDBC driver for it.

通常,Windows 二进制文件在不同的 Windows 版本上是兼容的——只要架构保持不变.如果您查看 SQLite 下载页面,您会注意到有一个 32 位预构建的 Windows二进制.这个几乎可以在任何 Windows 版本上使用(也许除了 Windows RT),但你不能在 Linux 或 OS X 上使用它.为了使用 Java 中的 SQLite,你需要包含特定操作系统的正确二进制文件/架构,有效地使 Java 应用程序依赖于平台.这是你通常不想要的.

Usually, Windows binaries are compatible over different Windows versions - as long as the architecture stays the same. If you look at the SQLite download page you'll notice there's a 32-bit pre-built Windows binary. This one can be used on almost any Windows version (except Windows RT, maybe), but you cannot use it on Linux or OS X. In order to use SQLite from Java, you would need to include the correct binary for the specific OS / architecture, effectively making a Java application platform-dependent. That is something you usually don't want.

如果您在 Swing 中构建桌面应用程序并且想要使用嵌入式数据库,我的建议是使用 Java 嵌入式数据库,例如 H2HSQL德比.后者也作为 JavaDB 随 Oracle Java 一起提供.所有都支持作为休眠方言(有关方言的完整列表,请参阅方言类:https://github.com/hibernate/hibernate-orm/tree/master/hibernate-core/src/main/java/org/hibernate/dialect)

If you're building a desktop application in Swing and you want to use an embedded database, my suggestion would be to use a Java embedded database, like H2, HSQL or Derby. The latter is also shipped with Oracle Java as JavaDB. All are supported as hibernate dialects (For a full list of dialects, see the dialect classes: https://github.com/hibernate/hibernate-orm/tree/master/hibernate-core/src/main/java/org/hibernate/dialect)

正如@akostadinov 在下面提到的,您可能还需要考虑其他因素,例如 SQLite 是用本机代码编写的,因此可能具有更好的性能.最终,唯一可以决定哪个数据库最好的人是构建系统的人.

As noted below by @akostadinov, there may be other factors you want to consider, for example the fact that SQLite is written in native code and hence may have better performance. In the end, the only one who can decide which database is best is the one who is building the system.

这篇关于Hibernate 是否完全支持 SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆