Issue
Is there a Hibernate dialect for Snowflake? I have seen some guides used SQLServerDialect (Refere this). Is it safe to use SQLServerDialect?
Solution
I search it on the internet and couldn't find a Dialect for that. Therefore the JdbcTemplate is used to access data as follows.
Added snowflake-jdbc driver maven dependency to the project.
<dependency> <groupId>net.snowflake</groupId> <artifactId>snowflake-jdbc</artifactId> <version>${snowflake.jdbc.version}</version> </dependency>
Created Entity classes as usual
Then JDBCTemplate to execute the SQL and prepare the results
@Autowired private JdbcTemplate jdbcTemplate; public List<AgeEntity> getByFilter(String test) { StringBuffer sql = new StringBuffer(); sql.append("SELECT AGE, COUNT \n"); sql.append("FROM Sample\n"); sql.append("WHERE a = "+test); return jdbcTemplate.query( sql.toString(), (rs, rowNum) -> new AgeEntity( rs.getString("AGE"), rs.getLong("COUNT") ) ); }
Answered By - Lakmal Vithanage
Answer Checked By - Cary Denson (JavaFixing Admin)