Hibernate show real SQL [duplicate]

Can I see (…) the real SQL If you want to see the SQL sent directly to the database (that is formatted similar to your example), you’ll have to use some kind of jdbc driver proxy like P6Spy (or log4jdbc). Alternatively you can enable logging of the following categories (using a log4j.properties file here): log4j.logger.org.hibernate.SQL=DEBUG … Read more

JPA JoinColumn vs mappedBy

The annotation @JoinColumn indicates that this entity is the owner of the relationship (that is: the corresponding table has a column with a foreign key to the referenced table), whereas the attribute mappedBy indicates that the entity in this side is the inverse of the relationship, and the owner resides in the “other” entity. This … Read more

What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do

From the community documentation: hibernate.hbm2ddl.auto Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly. e.g. validate | update | create | create-drop So the list of possible options are, validate: validate the schema, makes no changes … Read more

Spring + Hibernate manually creating transactions, PROPAGATION_REQUIRED fails. BUG?

You basically don’t use the transaction API as its intended to. The reference documentation is pretty precise about how to use programatic transactions: PlatformTransactionManager manager = … // obtain a transaction manager (DI) TransactionTemplate template = new TransactionTemplate(manager); template.execute(status -> { // Code to be execute in a transaction goes here. }); The important point … Read more