@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
时间: 2024-04-27 13:22:03 浏览: 9
`@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)` 是 JPA 中用来指定继承策略的注解之一。它表示使用表继承策略,即每个实体类对应一个单独的表,该表包含了该实体类及其子类的所有属性。在该表中,没有特殊的列用来标识实体类型,因此不会出现 `DTYPE` 列的问题。
使用 `@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)` 后,每个实体类都会对应一个单独的表,这些表之间没有任何关系,因此查询时需要使用 UNION ALL 来将它们合并。
该注解只能用在父类上,表示该父类为基类,所有子类都继承自该基类,并且使用表继承策略。同时,在父类上还需要使用 `@Entity` 注解来表示该类为实体类。
相关问题
<properties> <hudson.security.AuthorizationMatrixProperty> <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/> <permission>USER:hudson.model.Item.Read:anonymous</permission> </hudson.security.AuthorizationMatrixProperty> <jenkins.model.BuildDiscarderProperty> <strategy class="hudson.tasks.LogRotator"> <daysToKeep>90</daysToKeep> <numToKeep>-1</numToKeep> <artifactDaysToKeep>30</artifactDaysToKeep> <artifactNumToKeep>-1</artifactNumToKeep> </strategy> </jenkins.model.BuildDiscarderProperty> <com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.7.7"> <gitLabConnection>src.ift.run</gitLabConnection> <jobCredentialId/> <useAlternativeCredential>false</useAlternativeCredential> </com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty> <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.34"> <autoRebuild>false</autoRebuild> <rebuildDisabled>false</rebuildDisabled> </com.sonyericsson.rebuild.RebuildSettings> <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.11"> <maxConcurrentPerNode>3</maxConcurrentPerNode> <maxConcurrentTotal>0</maxConcurrentTotal> <categories class="java.util.concurrent.CopyOnWriteArrayList"/> <throttleEnabled>true</throttleEnabled> <throttleOption>project</throttleOption> <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams> <paramsToUseForLimit/> <configVersion>1</configVersion> </hudson.plugins.throttleconcurrents.ThrottleJobProperty> <jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.1071.v1a_188a_562481"> <durationName>hour</durationName> <count>40</count> <userBoost>true</userBoost> </jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl> </properties> 请解释这一段jenkins配置
这是一个Jenkins的配置文件,其中包含了一些插件和属性的设置。让我逐个解释每个部分的含义:
1. `<hudson.security.AuthorizationMatrixProperty>`:这个属性定义了Jenkins的授权矩阵,用于管理用户对项目的权限。在这个例子中,允许匿名用户对项目进行读取操作。
2. `<jenkins.model.BuildDiscarderProperty>`:这个属性定义了构建丢弃策略,用于控制构建历史的保存和删除。在这个例子中,使用了一个`hudson.tasks.LogRotator`策略,该策略会保留最近90天的构建日志,并且不限制保存的构建数量。
3. `<com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>`:这个属性是GitLab插件的设置,用于与GitLab服务器建立连接。在这个例子中,指定了GitLab服务器的地址为`src.ift.run`,并且没有指定作业凭据。
4. `<com.sonyericsson.rebuild.RebuildSettings>`:这个属性是重新构建插件的设置,用于控制是否启用自动重新构建功能。在这个例子中,禁用了自动重新构建功能。
5. `<hudson.plugins.throttleconcurrents.ThrottleJobProperty>`:这个属性是限制并发作业插件的设置,用于控制并发作业的数量。在这个例子中,限制每个节点同时运行的作业数量为3个,并且禁止全局并发限制。
6. `<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>`:这个属性是分支限制插件的设置,用于控制并发构建分支的数量。在这个例子中,限制每小时只能构建40个分支,并且允许用户提高并发限制。
这些配置属性可以根据需求进行修改,以满足特定的Jenkins项目需求。
More cats! Fill in this implemention of a class called NoisyCat, which is just like a normal Cat. However, NoisyCat talks a lot -- twice as much as a regular Cat! We may change the implementation of Pet and Cat while testing your code, so make sure you use inheritance correctly.其中class Pet: def __init__(self, name, owner): self.is_alive = True self.name = name self.owner = owner def eat(self, thing): print(self.name + " ate a " + str(thing) + "!") def talk(self): print(self.name) class Cat(Pet): def __init__(self, name, owner, lives=9): super().__init__(name, owner) self.lives = lives def talk(self): print(self.name + " says meow!") def eat(self, thing): super().eat(thing) def lose_life(self): if self.lives > 0: self.lives -= 1 if self.lives == 0: self.is_alive = False else: print(self.name + " has no more lives to lose.")
Here is the implementation of the NoisyCat class that inherits from the Cat class:
```
class NoisyCat(Cat):
def talk(self):
print((self.name + " says meow! ") * 2)
```
The NoisyCat class overrides the `talk` method of the Cat class to make the cat talk twice as much. The `super` function is not used in this implementation because we want to completely override the `talk` method.