java - 通过 JPA 保存 List<String> 时出现问题?

标签 java orm jpa jpa-2.0

我已经看过了

How to persist a property of type List<String> in JPA?

Map a list of strings with JPA/Hibernate annotations

============================================= ==============================

我正在努力挽救

List<String>

通过 JPA。我开始知道 JPA 1.0 没有任何方法来持久保存非实体类的集合,但 JPA 2.0 包含了 @CollectionOfElements 注释。

首先,我不确定要使用哪个 JPA 2.0 实现。早些时候我使用的是 toplink-essentials,但它没有 @CollectionOfElements 注释。

我下载了 eclipse-link 但没有在其中找到任何 jar 文件。

所以我的问题是要使用哪个 JPA 2.0 实现来提供 jar 文件,以便我可以将这些 jar 包含在我的项目中,就像我对 toplink-essentials 所做的那样。

最佳答案

First, I am not sure which JPA 2.0 implementation to use. Earlier I was using toplink-essentials but it doesn't have @CollectionOfElements annotation.

TopLink-Essential 不是 JPA 2.0 实现。正如 James 所指出的,请注意 JPA 2.0 注释是 @ElementCollection@CollectionOfElements 是 Hibernate 特定的注释,现在已弃用,取而代之的是 JPA 注释。

I downloaded eclipse-link but didn't find any jar files inside it.

你下载了什么?您可以从 download page 获得的 EclipseLink 2.1.1 安装程序 Zip (28 MB)在 jlib 目录中包含一个一体化的 jar。

So my question is to which JPA 2.0 implementation to use which provides jar files so that I can include those jars in my project as I have done for toplink-essentials.

其中任何一个。我个人会使用 Hibernate 3.5.x 或 EcliseLink 2.x,您可以分别从

引用

  • JPA 2.0 规范
    • 第 11.1.12 节“ElementCollection 注释”

关于java - 通过 JPA 保存 List<String> 时出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3674191/

相关文章:

java - 我如何分离一个字符串,以便 "cat!"将是 "cat !"

postgresql - 为 postgres 灵活映射记录数组

spring - 如何使用Hibernate JPA和Spring Framework启用加载时间/运行时编织

java - Spring Data JPA 的 CustomRepositoryImpl 在 IntelliJ 中显示 "Never Used"

java - 远程调试 Spring Boot 应用程序

java - 除以 1.0/0.0 : output is infinity

java - 无法启动新的 Android Activity

reflection - Automapper 与运行时通过配置文件和反射进行映射

php - mysql——创建新表还是不创建

java - GAE、JPA、XG-transactions、太多实体组异常