I have an JPA Entity which I Would like to use for 2 Tables.
@Entity
@Table(name="table_name_should_be_injected")
class MyEntity{
// Implementation goes here
}
So I would like to inject the table name with Spring.
Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Please don’t pursue this line of design. It will add a completely unnecessary level of complexity to your solution, it goes against the JPA specification and intention and it will leave anyone else looking at your solution scratching their heads.
The proper way to accomplish this in JPA is with an abstract base-class and
@Inheritance(strategy=TABLE_PER_CLASS)(see @Inheritance).