javax.persistence.transient和java.bean.transient是否做同样的事情? [英] Do javax.persistence.transient and java.bean.transient do the same thing?

查看:863
本文介绍了javax.persistence.transient和java.bean.transient是否做同样的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javax.persistence.transient 注释和 java.beans.transient 注释是否做同样的事情?我知道后者仅在Java 7中引入。我只是很好奇,因为我们最近升级到了我们的服务器上的Java 7,我想知道Hibernate是否可以与任一注释一样工作。

解决方案

正如@Wundwin Born之前所说:

javax.persistence.transient将确保Hibernate将忽略该特定字段,将其保存到数据库中,反之亦然。



java.beans.transient将确保特定字段将被编码器忽略(源自编码器)。请参阅 http://docs.oracle.com/javase/ 7 / docs / api / java / beans / Transient.html

Does the javax.persistence.transient annotation and the java.beans.transient annotation do the same thing? I know that the latter was only introduced in Java 7. I'm just curious as we recently upgraded to Java 7 on our servers and I'm wondering if Hibernate will work the same with either of the annotations.

解决方案

As @Wundwin Born said before:

javax.persistence.transient will make sure that Hibernate will ignore that particular field from saving it into the db and vice-versa.

java.beans.transient will make sure that the particular field will be ignored by the encoders (derived from Encoder). See http://docs.oracle.com/javase/7/docs/api/java/beans/Transient.html

这篇关于javax.persistence.transient和java.bean.transient是否做同样的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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