Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 将值注入JPA表注释_Spring_Jpa_Annotations_Code Injection - Fatal编程技术网

Spring 将值注入JPA表注释

Spring 将值注入JPA表注释,spring,jpa,annotations,code-injection,Spring,Jpa,Annotations,Code Injection,我有一个JPA实体,我想用于2个表 @Entity @Table(name="table_name_should_be_injected") class MyEntity{ // Implementation goes here } 所以我想用Spring注入表名。 这可能吗?请不要追求这一设计路线。这将给您的解决方案增加完全不必要的复杂性,这与JPA规范和意图背道而驰,并且会让其他人对您的解决方案刮目相看 在JPA中实现这一点的正确方法是使用抽象基类和继承(strat

我有一个JPA实体,我想用于2个表

@Entity
@Table(name="table_name_should_be_injected")
class MyEntity{
  // Implementation goes here
}
所以我想用Spring注入表名。
这可能吗?

请不要追求这一设计路线。这将给您的解决方案增加完全不必要的复杂性,这与JPA规范和意图背道而驰,并且会让其他人对您的解决方案刮目相看

在JPA中实现这一点的正确方法是使用抽象基类和继承(strategy=TABLE\u PER\u class)(请参阅)