gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:05:07 25 4
gpt4 key购买 nike

我想知道下面的代码如何影响Java playframework中的数据库创建和数据访问

public Boolean isactive;

Boolean isactive;

最佳答案

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

  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.

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

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

关于java - PlayFramework 模型中 public Boolean isactive 和 Boolean isactive 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34992084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com