I am generating my classes using spring jpa template in Telosys generator tool. It works as expected, however, my project has different database schemas for different environment which I can't handle. So my entity classes need to have respective schema name which will mean me connecting each database schema and generating environment specific classes.
I am trying to pass the schema name from gradle variable and use that in entity class
schema = "${property.schema.name}"
But since these are generated classes by Telosys, all JPA annotations are handled by the template. Is there a way to set the schema name in the annotation like above? or any alternate solution to the problem of different schemas is appreciated
If your database schema is the same for all entities you can just define a specific project global variable in the file "telosys-tools.cfg".
See : https://doc.telosys.org/configuration-and-variables
In your case:
ProjectVariable.DBSCHEMA = yourschemaYou can use it directly in the templates with
${DBSCHEMA}:If you have specific schema only for certain entities you can use the
@DbSchema(your-schema-name)annotation (at entity level) in the ".entity" filesSee : https://doc.telosys.org/dsl-model/annotations#dbschema-string
Annotations like
@DbSchemaand@DbCatalogare automatically used by$jpaobject in the templates.