What’s the difference between session.persist() and session.save() in Hibernate?

From this forum post persist() is well defined. It makes a transient instance persistent. However, it doesn’t guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. The spec doesn’t say that, which is the problem I have with persist(). persist() also guarantees that it will not execute an … Read more

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

First remove all of your configuration Spring Boot will start it for you. Make sure you have an application.properties in your classpath and add the following properties. If you really need access to a SessionFactory and that is basically for the same datasource, then you can do the following (which is also documented here although for XML, not JavaConfig). That way … Read more

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

For the record, the spring.jpa.hibernate.ddl-auto property is Spring Data JPA specific and is their way to specify a value that will eventually be passed to Hibernate under the property it knows, hibernate.hbm2ddl.auto. The values create, create-drop, validate, and update basically influence how the schema tool management will manipulate the database schema at startup. For example, the update operation will query the JDBC driver’s API to … Read more

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

First remove all of your configuration Spring Boot will start it for you. Make sure you have an application.properties in your classpath and add the following properties. If you really need access to a SessionFactory and that is basically for the same datasource, then you can do the following (which is also documented here although for XML, not JavaConfig). That way … Read more

Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL

Upgrade MySql driver to mysql-connector-java – 8.0.17 and Those who are using greater than MySQL 5.5 version change their driver property from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver because: Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.INFO – HHH000401: using driver [com.mysql.jdbc.Driver] at … Read more

How to fix org.hibernate.LazyInitializationException – could not initialize proxy – no Session

What is wrong here is that your session management configuration is set to close session when you commit transaction. Check if you have something like: in your configuration. In order to overcome this problem you could change the configuration of session factory or open another session and only than ask for those lazy loaded objects. … Read more

No more data to read from socket error

For errors like this you should involve oracle support. Unfortunately you do not mention what oracle release you are using. The error can be related to optimizer bind peeking. Depending on the oracle version different workarounds apply. You have two ways to address this: upgrade to 11.2 set oracle parameter _optim_peek_user_binds = false Of course underscore parameters … Read more

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

First remove all of your configuration Spring Boot will start it for you. Make sure you have an application.properties in your classpath and add the following properties. If you really need access to a SessionFactory and that is basically for the same datasource, then you can do the following (which is also documented here although for XML, not JavaConfig). That way … Read more

Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Cause: The error occurred since hibernate is not able to connect to the database.Solution:1. Please ensure that you have a database present at the server referred to in the configuration file eg. “hibernatedb” in this case.2. Please see if the username and password for connecting to the db are correct.3. Check if relevant jars required for … Read more