Hibernate executes commands that I didn't write. Why could that be?

Hibernate executed commands that I didn’t write. As you see, I didn’t tell Hibernate to drop anything nor to interact with the database in any way at all. However, it executed all these commands nonetheless. Earlier, I encountered a similar issue when Hibernate executed old code instead of new one. Why could that be?

I have an inkling that Hibernate executes the code that was last installed via Maven, even if there are some changes afterwards

The drop table and create table statements are executed because you use hibernate.hbm2ddl.auto=create-drop. When the SessionFactory is built, it will then drop an create tables.
I don’t know where the insert statements are coming from, but you seem to already have figured out that you are probably running code from a previous compilation/publish run. I don’t know how your run configuration in IntelliJ looks like, but it’s not a problem with Hibernate. Inspect the JARs that are used for this run configuration to see what code is executed. If you have further questions about this, please ask these questions on StackOverflow, as the problem has nothing to do with Hibernate.

1 Like