What is the significance of @javax.persistence.Lob annotation in JPA?(JPA中@javax.persistence.Lob注解有什么意义?)
问题描述
我什么时候应该在 JPA 中使用 @javax.persistence.Lob 注释?这个注解可以注解哪些数据类型?
@javax.persistence.Lob
表示注解的字段应该在DataBase中表示为BLOB(二进制数据).p>
您可以使用此注解来注解任何 Serializable
数据类型.在 JPA 中,在持久化(检索)后,字段内容将使用标准 Java 序列化进行序列化(反序列化).
@Lob
的常见用途是在 Entity 中注释 HashMap
字段以存储一些未映射到 DB 列的对象属性.这样,所有未映射的值都可以以二进制表示形式存储在数据库中的一列中.当然,付出的代价是,由于它们以二进制格式存储,因此无法使用 JPQL/SQL 进行搜索.
When should I use @javax.persistence.Lob
annotation in JPA? What datatypes can be annotated by this annotation?
@javax.persistence.Lob
signifies that the annotated field should be represented as BLOB (binary data) in the DataBase.
You can annotate any Serializable
data type with this annotation.
In JPA, upon persisting (retrieval) the field content will be serialized (deserialized) using standard Java serialization.
Common use of @Lob
is to annotate a HashMap
field inside your Entity to store some of the object properties which are not mapped into DB columns. That way all the unmapped values can be stored in the DB in one column in their binarry representation. Of course the price that is paid is that, as they are stored in binary format, they are not searchable using the JPQL/SQL.
这篇关于JPA中@javax.persistence.Lob注解有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JPA中@javax.persistence.Lob注解有什么意义?
基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01