@Javax.persistence.Lob注释在JPA中有什么意义? [英] What is the significance of @javax.persistence.Lob annotation in JPA?

查看:195
本文介绍了@Javax.persistence.Lob注释在JPA中有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该何时在JPA中使用 @ javax.persistence.Lob 注释?此批注可以注释哪些数据类型?

When should I use @javax.persistence.Lob annotation in JPA? What datatypes can be annotated by this annotation?

推荐答案

@ javax.persistence.Lob 表示带注释的字段应在数据库中表示为BLOB(二进制数据)。

@javax.persistence.Lob signifies that the annotated field should be represented as BLOB (binary data) in the DataBase.

您可以注释任何可序列化带有此注释的数据类型。
在JPA中,在持久化(检索)后,字段内容将使用标准Java序列化进行序列化(反序列化)。

You can annotated any serializable data type with this annotation. In JPA, upon persisting (retrieval) the field content will be serialized (deserialized) using standard Java serialization.

LOB的常用用途是注释<您实体中的code> HashMap 字段,用于存储未映射到数据库列的一些对象属性。这样,所有未映射的值都可以在其二进制表示中的一列中存储在DB中。当然,支付的价格是,因为它们以二进制格式存储,所以它们不能使用JPQL / SQL进行搜索。

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.

这篇关于@Javax.persistence.Lob注释在JPA中有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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