Hi Team,

I am facing a type cast issue as given below:

Jooq version: 2.6.0


org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; 
bad SQL grammar [insert into hsbcr_abstractbaserate (createdon, modeltype, 
active, id, notes, branchid, code, previousratevalue, concretemodeltype, 
businessdatecreatedon, modifiedon, modelid, description, rate, 
businessdatemodifiedon, repositoryid, parentrevision, revision, name, 
previousvaluedate, valuedate) values (cast(? as timestamp), cast(? as 
varchar), cast(? as int), cast(? as varchar), cast(? as varchar), cast(? as 
varchar), cast(? as varchar), cast(? as numeric), cast(? as varchar), 
cast(? as timestamp), cast(? as timestamp), cast(? as varchar), cast(? as 
varchar), cast(? as numeric), cast(? as timestamp), cast(? as varchar), 
cast(? as numeric), cast(? as numeric), cast(? as varchar), *cast(? as 
varchar)*, cast(? as timestamp))]; nested exception is 
org.postgresql.util.PSQLException: ERROR: column "previousvaluedate" is of 
type timestamp without time zone but expression is of type character varying


the Query is generated by using the jooq getSQL(). It is casting null into 
varchar instead of timestamp and is not supported in PostgreSQL.

Please find the code snippet as below:

final InsertValuesStep<Record> insertQuery = 
jooqFactory.insertInto(Factory.tableByName(table), 
fieldArray).values(values);
final List<Object> bindValues = insertQuery.getBindValues();
final String sql = insertQuery.getSQL();
List<Object[]> list = queryMap.get(sql);
if (list == null) {
         list = Lists.newArrayList();
         queryMap.put(sql, list);
}
list.add(bindValues.toArray());


Can some one please help

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to