reset password
Author Message
ummata
Posts: 68
Posted 16:12 Oct 09, 2012 |

Hello all,

From Hibernate project, Hbm2ddl.java  is a class to export SQL from java classes.
But I don't think it can generate "Alter table" in case I modify or add more fields to tables later on.

Do we have any tools that can bind java objects to database schema?
So that we can modify schema at one place in java files and no SQL generated involved.

cysun
Posts: 2935
Posted 17:07 Oct 09, 2012 |

You can change the Hbm2ddl code to export the schema directly to the database (see the API doc for SchemaExport), but a) you still have to manually run it, and b) I believe it drops then recreates all the tables instead of using ALTER TABLE. Generating ALTER TABLE is quite difficult. I don't know any tool that can do that (if you know one, please let me know because I certainly want to use it).