Can I automatically update hibernate pojos and mappings in Netbeans after adding a new table?

I already have the hibernate and pojos mapping files created by Netbeans, to which I have added named queries and additional methods.

Now I have added another table to the database and a foreign key column to the existing table.

It is not a big problem with a single table to add the mappings manually, but it becomes tedious and prone to errors with a large number.

I am currently using the wizard to create an entire new set of classes and mappings in a new package and manually merge, which is error prone in itself.

Is there a way to automatically update .hbm and java files?

+3
source share
2 answers

What you are trying to achieve is not the best way to synchronize the database and sleep mode. If possible, you should do the opposite: make changes to the sleep mode mappings and let them be reflected in the database.

After all, it is your object model that matters, not the database view.

Check out the property hibernate.hbm2ddl.auto here . If set update, it will update the base database with the appropriate columns and constraints based on changes in your sleeping mappings.

+5
source

NetBeans 6.5, , , round-trip. , , , .

+2

Source: https://habr.com/ru/post/1729761/


All Articles