Issue with "language" keyword, after upgrading h2 database to 2.1.210 - h2

I am currently working on spring boot jpa applicaiton. it used to work normally with h2 1.4.196.
After I upgrade to h2 to latest version(2.1.210). I am facing issues with the application.
I am facing issues with using reserved keywords in application. I have used key, value as fields in a class. I am able to solve this problem by using below statement.
spring.jpa.properties.hibernate.auto_quote_keyword = true,
above property puts quotes around the keywords which are used in application.
after using above property I am able to compile the application successfully, but while application is running I am facing issue with a field "language" that I used in application.
what I am guessing is, language is normally generated in liquibase generated database, but while querying, hibernate is putting "quotes" around language, thus producing a mismatch and giving error
Can someone please help to solve the issue.
Below is the generated sql from spring boot
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "USER0_.language" not found; SQL statement:
select user0_.id as id1_1_, user0_.dashboard_order as dashboar2_1_, user0_.date_format as date_for3_1_, user0_.user_email as user_ema4_1_, user0_."language" as language5_1_ from blu_dash_user user0_ where upper(user0_.user_email)=upper(?) [42122-210]

had same situation my manager found on stack overflow a solution,
u can add in connection string list of key words to be permitted, example of connection string jdbc:h2:./test;NON_KEYWORDS=KEY,VALUE
hope will help folks

Related

Old style outer join (+) cannot be used with ANSI joins, Oracle Database Error Code ORA-25156

Why I get this error even though i specified the hibernate.dialect as OracleDialect. If you recommend to use oracle10gDialect or Oracle9iDialect please explain, cause Hibernate can find the Dialect using JDBC meta data when it connect to the db in very first time. Correct me if i'm wrong.
I believe your problem is to find the correct dialect. But I believe this is part of the configuration. This is not a programming problem, This is a configuration strategy that you used to manipulate or use of configuration.
you can externalize the configuration with multiple profiles such as dev, UAT, PROD which is based on the environment. Then your CICD
the pipeline will pick the correct profile which has the correct dialect according to the deployed environment.
Or you can add default dialect and override the properties based on
the environment in which the application is deployed.
The reason is application is the component where looking for the database.
or check this post if you wanted to do programmatically ( I haven't try this) :
Is there a way to detect SQL Dialect without knowing the database type?
Also please read the driver specification and JPA dialect usage. some databases expect exact versions of dialect to support full functionality.

Is it possible to supply render settings for jOOQ code generation?

I'm trying to run the jOOQ code generator against an H2 database, but am encountering the following exception:
23:59:27.191 [main] ERROR org.jooq.meta.AbstractDatabase - Could not load schemata
org.jooq.exception.DetachedException: Cannot execute query. No Connection configured
at org.jooq_3.11.7.MYSQL.debug(Unknown Source)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:319)
...
I have verified that the database does in fact exist. I suspect this is due to a mismatch in case-sensitivity handling:
jOOQ quotes names for all schema objects as a means of specifying case-insenstivitiy... however,
H2 uses quotes to enforce case-sensitivity.
I'm aware of how to specify render settings programmatically to use generated artifacts (building queries and such), but in this particular case I'm looking for a way to specify those settings in configuration for the code generator.
Thanks in advance!
The artificial stack trace element at org.jooq_3.11.7.MYSQL.debug(Unknown Source) indicates that you're using the SQLDialect.MYSQL dialect to generate your SQL code, which obviously doesn't work on H2. Also, your Configuration doesn't have a JDBC connection as the error message indicates, so you cannot actually execute any queries through jOOQ.
The code generator doesn't offer the functionality you're looking for. In order to "unquote" all identifiers, use the identifier style settings at runtime.

Not running DDL scripts with spring batch + spring boot + sql server application

My project has this requirement where user uploads a CSV file which has to be pushed to sql server database.
I am following the below basic example to load CSV file into a sql sever database.
https://github.com/michaelcgood/Spring-Batch-CSV-Example
runninng this repo by making change of datasource, here we using sql server instead of in-memory db.
here is the addition to POM file:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<</dependency>
additions to applications.properties file
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=springbootdb
spring.datasource.username=sa
spring.datasource.password=Projects#123
Below is the error generated while running the code base, we could not found exact root cause we tried the multiple approaches as mentioned in the google but no luck, while running this spring batch+spring boot 2.0.4 application we are facing the below errors:
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
o.s.boot.autoconfigure.jdbc.Datasource.initailizer disabled(not running DDL scripts)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE
where JOB_NAME = ? order by JOB_INSTANCE_ID desc]; nested exception is java.sql.SQLServerException: Invalid object name 'BATCH_JOB_INSTANCE'.
We are assuming the root cause one of the below?
1.We are using the spring starter project for creating spring batch configuration so not aware how we could define the default table schema and all.
2.maybe we don't have access and/or you need to define the schema. http://forum.spring.io/forum/spring-projects/batch/63771-badsqlgrammarexception-running-commandlinejobrunner
3.Not sure on the why error is saying Invalid object name 'BATCH_JOB_INSTANCE' instead of object doesnot exist?
What are the list of sql queries to create metadate table for spring batch application, to create it manually before running application.
4.we are struggling from couple of days to find the root cause of issue, Please suggest approch by taking the above github code base sample.
any help here would be appreciated. Please let us know if we missed anything here. Thanks In advance
The project you are linking to uses the in-memory hsqldb instance so Spring Boot will automatically create Spring Batch meta-data tables for you.
If you want to adapt the sample to your project and use sql server (which is not embedded in your JVM), Spring Boot will not create Spring Batch tables (unless you instruct it to do so). In this case, you have two options:
Run the Spring Batch DDL script for sqlserver yourself against the db server you are using before running your app
Or instruct Spring Boot to do it for you by specifying the following properties in your application.properties file:
spring.batch.initialize-schema=always
spring.batch.schema=classpath:org/springframework/batch/core/schema-sqlserver.sql

HSQLDB user lacks privilege or object not found error when making select statements in Spring Boot

I have gone through Stack overflow existing scenarios of why we are getting this error.
I have just simple person class and a service for which I am writing a test case using embedded database. There is no problem in the code but it is not creating database.
I had the same problem and when I started to read the logs, I saw that, it couldn't create a table, because one of my string fields was annotated with #Column(columnDefinition = "TEXT").
So, most of the cases it can't create/select from a table, not because you don't have access to it. Just read your logs, and see what is the problem with creating/selection the table.

WebLogic ModuleException on Hibernate Dialect

The database group recently upgraded the database to Oracle12c. I am currently using Hibernate 4.3.9. When I try to deploy the application, WebLogic throws an exception:
weblogic.application.ModuleException: org.hibernate.HibernateException: Unable to determine dialect to use [name=Oracle, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'.
HibernateUtil has
props.setProperty("hibernate.dialect", "utilities.OracleDialectExtended");
Where OracleDialectExtended extends Oracle10gDialect in order to register a Double as a float. HibernateUtil is being used to set the properties rather than in hibernate.cfg.xml.
Everything I have read indicates that using Oracle10gDialect should be OK. In fact, when I use the same set up in a batch type mode (not using WebLogic) I am able to connect with and work with Oracle without a problem.
Does anyone know how to resolve this? Or is this a WebLogic problem that needs to be addressed by a WebLogic admin.
Thanks.
Try with this:
props.setProperty("hibernate.dialect","org.hibernate.dialect.OracleDialect");
Just to follow up - in the end I upgraded Hibernate from 4.3.9 to 5.1.2 and things started working again.
Not the most ideal solution since a database upgrade shouldn't break an application but it was the fastest way to get things up and running again.

Resources