0
How do I use the annotation @Table
of Hibernate using a variable that brings the table name for example @Table(name = "dep4"+Dados.getCodEmp)
? 'Cause I’m using it that way but I was presented with the following mistake:
The value for annotation attribute Table.name must be a constant expression
I need this because in the database of the system in question the tables are generated with the following prefix nomenclature + the code assigned to the company, for example dep4+(CodEmp)
. This code I take from a text file that is inside the application directory.
I can do one thing, but I don’t understand this
"dep4"+Dados.getCodEmp
. Is that the table name or would it be a "prefix"? Type:("dep4"+Dados.getCodEmp) + "_nome_da_tabela"
– Renan Gomes
The "dep4"+Data.getCodEmp would be the name of my table, where the dep4 is the default prefix of the table name Data.getCodEmp is where I get the company code to compose the table name. For example I am logged in to the bank with the code company 01 then the name of my table would be dep401
– Camila
Oh yes, the solution I had as a suggestion was for another purpose. You can generate the names dynamically, but not by annotating
@Table
: https://stackoverflow.com/a/1507980/4056678– Renan Gomes