jaxio / celerio

Celerio is a code generator tool for data-driven application.
Apache License 2.0
80 stars 35 forks source link

Table Schema and Catalog #4

Closed sergiofm closed 7 years ago

sergiofm commented 7 years ago

Hi there.

I'm using Celerio to generate code from a SqlServer Database and I need to generate the entitys with the @Table annotation like this @Table(catalog = "Catalog", schema = "Schema", name = "Table"). I've looked the code and this annotation seems to be generated with only the name attribute, so I'm trying to modify my template, but I didn't find a way to get the Schema and the Catalog for a entity. Can you help me with that? Thanks

nromanetti commented 7 years ago

Indeed! Thanks for pointing this out. I have implemented it in Celerio 4.0.20. Could you please test it and let me know how it goes.

sergiofm commented 7 years ago

Wow, that was fast! I've tryied and it worked! But, we have some special requirement here. Let me explain. We have one catalog, with more than one schema on it. The tables from one schema have relationship with tables from another schema, so we need to generate the code for the entire catalog at once. To do that, I used % as the schema in the pom.xml configuration, and the code was well generated, unless for one thing, the anotation was generated with % in the schema attribute. I believe that attribute came from the pom.xml configuration, right? Is it possible to get that attribute from table metadata instead of the configuration? Our project is really big, and change all the entities by hand will be very expensive. Again, thank you very mutch for your effort. This project is amazing!

nromanetti commented 7 years ago

OK, I see. In your case, can 2 tables living in 2 different schemas may have the same name ?

sergiofm commented 7 years ago

In our case not. But I think that separate entities for each schema can be a good idea. Maybe a subpackage per schema. Like models.schema.Entity

nromanetti commented 7 years ago

I have reworked this issue. Please read the change log for release 4.0.21. Make sure to run the db reverse with 4.0.21 in order to fetch the schema/catalog from jdbc table metadata.

Let me know how it goes! I am also curious to know more about your schemas (how many tables in total?). Cheers

sergiofm commented 7 years ago

We're migrating a big system for a new archtecture witch is identical as the angular-quickstart generates, for our luck! :) Today we have more than 60 tables, separeted in 3 schemas, but the project is in early stages, and it still will grow to around 80 tables. I've tested the change, and it works well! And I did liked the configurations options. Is really better this way. Our team decided to make a fork of your project and soon we will make some contributions too. Thank you very mutch for your effort. This project is really nice and we're glad to help improve it!

nromanetti commented 7 years ago

Great, thanks for your feedbacks, I am glad it is useful.