With Hibernate 6 table and column name are not correctly coming in SQL

Hi,
I have migrated from Hibernate 5.3.X to 6.1.5 . But my queries are failing.

“An unknown exception is thrown : JDBC exception executing SQL [select count(*) from "Table_Name" d1_0 where d1_0."Table_Name"=?]; SQL [n/a]”

Getting table not exists as there are escape character and quotes in table and column name.

I tried setting this property in application.properties but no luck.

spring.jpa.properties.hibernate.globally_quoted_identifiers=true

Could you please help to resolve this

Please show us the entity mapping and the configuration you are using.

@Bean(name = “filenetEntityManagerFactory”)
public LocalContainerEntityManagerFactoryBean filenetEntityManagerFactory() throws NamingException, SQLException {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(filenetDataSource());
em.setPackagesToScan(“com.atradius.dms.model.entity.filenet”);
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	HashMap<String, Object> properties = new HashMap<>();
	//properties.put("hibernate.dialect", hibernateDialect);
	properties.put("hibernate.globally_quoted_identifiers", "true");
	properties.put("hibernate.format_sql", "true");
	properties.put("hibernate.show_sql", "true");
	properties.put(AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS,"true");
	properties.put("spring.jpa.properties.hibernate.globally_quoted_identifiers","true");

	em.setJpaVendorAdapter(vendorAdapter);
	em.setJpaPropertyMap(properties);
	//For DB logging
	try(OracleConnection connection = (OracleConnection) filenetDataSource().getConnection()){
		LOGGER.info("DB URL for Filenet Datasource- "+connection.getMetaData().getURL());
		LOGGER.info("DB Username for Filenet Datasource- "+connection.getMetaData().getUserName());
	}catch(SQLException e) {
		L	@Bean(name = "filenetDataSource")
// @ConfigurationProperties(prefix = "spring.second-datasource")
public DataSource filenetDataSource() {

	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
	dataSource.setUrl("jdbc:oracle:thin:@XXX.XXX.com:XX:XXX");
	dataSource.setUsername("XXX");
	dataSource.setPassword("XXX");//TEST_OGET1");


	//dataSource.setUrl("jdbc:oracle:thin:@XXXX");// ${url}");//
	//dataSource.setUsername("XXX");// ${username}");
	//dataSource.setPassword("XXXX");// ${password}");

// dataSource.setUrl(“jdbc:oracle:thin:@XXXX.com:1616:OGET”);
// dataSource.setUsername(“XXXX”);
// dataSource.setPassword(“XXXX”);//TEST_OGET1");
return dataSource;
}OGGER.error("DB connection could not be established for Filenet Datasource: "+e.getMessage());
throw new SQLException(e.getMessage()); }
return em;
}

Using CRUDRepository existsBy method to check if id is present or not , so getting this query hitting database

An unknown exception is thrown",“internalErrorMessage”:“JDBC exception executing SQL [select count(*) from "F_XXX" d1_0 where d1_0."F_ID"=?] [ORA-00942: table or view does not exist\n] [n/a]; SQL [n/a]”}}

After migration to hibernate latest version and spring boot 3only this error is encountered.

You configured quoted identifiers, so Hibernate respects that and quote identifiers.

If you don’t know what that means or how Oracle treats such identifiers, then you should not use it.

@beikov

I tried removing this property but still getting the same.

Hibernate Query generated
select
count(*)
from
“F_Table” d1_0
where
d1_0.F_ID=?
22-08-2023 02:11:48.658 WARN [05df77fe-aa16-40d5-8f67-6088b72ce8b7]- SQL Error: 942, SQLState: 42000
22-08-2023 02:11:48.658 ERROR [05df77fe-aa16-40d5-8f67-6088b72ce8b7]- ORA-00942: table or view does not exist

Entity mapping

@Data
@Table(name =“F_Table”)
@Entity
public class Document {

/**

  • Id of the Document.
    */
    @Id
    @Column(name = “F_ID”)
    private Long id;
    }

Then you didn’t remove the property the right way. Look harder.
Hibernate does not quote such simple identifiers unless you configure that property.