Java bean:持久性字段和持久性属性之间的区别? [英] java beans: difference between persistent field and persistent property?

查看:121
本文介绍了Java bean:持久性字段和持久性属性之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的印象是,如果我们使用持久字段,则不需要getter方法,因为实体管理器直接引用了实例变量.但是,当我从实体中删除getter和setter方法以具有持久字段时,未从数据库中检索到相应实例变量的值!

I got the impression that if we use persistent fields, there is no need for getter methods since the entity manager references the instance variables directly. However, when I removed the getter and setter methods from an entity to have persistent fields, the values for the corresponding instance variable was not retrieved from the database!

这是否意味着即使我们具有持久字段,我们也必须具有getter和setter方法?

Does that mean we must have getter and setter methods even though we have persistent fields?

推荐答案

如果实体类使用持久性,则字段Persistence会在运行时直接访问实体类实例变量.

If the entity class uses persistence, fields Persistence accesses the entity class instance variables directly at runtime.

在持久性属性上,每个属性都有一个getter和setter方法.

While on persistence property, there is a getter and a setter method for each property.

您所说的应该在休眠状态下起作用.

What you said should have worked on hibernate.

关于它的链接

这篇关于Java bean:持久性字段和持久性属性之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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