IntelliJ doesn't update schema after changing hibernate entity

已回答

Hello,

I am a new IntelliJ Ultimate user. I am struggling with a basic functionality -- synchronizing model with a database schema.

I have created a new database with one table, configured hibernate framework support and generated a persistence mapping. So far so good. Then I tried to:

- Add an entity to ER diagram

- Add a relation in ER diagram

- Add a column in entity source code

None of those changes were reflected in the (postgres) database. I'm pretty sure that it's configured correctly - I can eg. "generate persistence mapping" and actually save data using Hibernate code (openSession, persist etc.).

I also tried to add a column in a database and it wasn't reflected in model neither, until I manually regenarated mappings (this is a minor issue, the code-first approach is more important).

What am I missing? How to get it working?

I'd like to make a change to a model and don't need to think about anything else. Then I can commit generated up and down migrations in git so anybody in a team can migrate a database in both directions. Something like checking "enable automatic migrations" in EF (https://msdn.microsoft.com/en-us/data/jj591621).

Greetings, Jacek.

0

>None of those changes were reflected in the (postgres) database. 

Currently the changes you do in Database diagram are not auto-synchronized with the database. So you would need to create or modify tables/relations via UI form from the action invoked for the data source schema.

One may vote/follow this related request in the tracker: https://youtrack.jetbrains.com/issue/DBE-1248

>I also tried to add a column in a database and it wasn't reflected in model neither

The change should be in effect actually. Please try to invoke Synchronize for the data source after you add.modify the database object.

0

Thanks for a quick answer.

I have introduced Liqui Base to the project . It seems to be a nice workaround until IntelliJ/hibernate supports code-first migrations. About your point about "Synchronize" - I meant that the changes weren't reflected in hibernate entities. However, I consider leaving Hibernate in favour of Speedment anyway. I'm not sure if it's a good idea, though (no pun intended).

0

请先登录再写评论。