public Boolean isactive 和 PlayFramework 模型中的 Boolean isactive 之间的区别

Difference between public Boolean isactive and Boolean isactive in PlayFramework Models

我想知道下面的代码如何影响 Java playframework

中的数据库创建和数据访问
public Boolean isactive;

Boolean isactive;

要了解这种差异如何影响数据访问,您必须了解如何控制对 class:

字段的访问
  1. https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
  2. In Java, difference between default, public, protected, and private

At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

然后,@PiNg2Eiw 链接的页面解释了 Play Enhancer 如何使用这些声明来自动添加 setter 和 getter:

The enhancer looks for all fields on Java classes that:

  • are public
  • are non static
  • are non final

For each of those fields, it will generate a getter and a setter if they don’t already exist. If you wish to provide a custom getter or setter for a field, this can be done by just writing it, the Play enhancer will simply skip the generation of the getter or setter if it already exists.

此外,数据库的创建在很大程度上取决于您映射模型的方式 classes。请参阅以下文档:

  1. http://ebean-orm.github.io/docs/mapping/
  2. https://www.playframework.com/documentation/2.4.x/JavaEbean