Skip to content

Oracle : Fix java.time.* generated values #1276

@pull-vert

Description

@pull-vert

Context

I encountered an exception when I want to obtain java.time.* values from an Oracle table that have default values.

Version

4.3.8

Steps to reproduce

  1. Execute create table
var create = "CREATE TABLE EntityWithDefaultValues\n" +
            "(\n" +
            "    id NUMBER(10) NOT NULL,\n" +
            "    string VARCHAR2(255) DEFAULT 'default' NOT NULL,\n" +
            "    localDate DATE DEFAULT date '2019-11-04' NOT NULL,\n" +
            "    localDateTime TIMESTAMP DEFAULT timestamp '2018-11-04 00:00:00' NOT NULL,\n" +
            "    inte NUMBER(10) DEFAULT 42 NOT NULL,\n" +
            "    longe NUMBER(19) DEFAULT 84 NOT NULL,\n" +
            "    floate BINARY_FLOAT DEFAULT '42.42' NOT NULL,\n" +
            "    doublee BINARY_DOUBLE DEFAULT '84.84' NOT NULL,\n" +
            "    bigDecimal NUMBER(3,1) DEFAULT '4.2' NOT NULL,\n" +
            "    offsetDateTime TIMESTAMP WITH TIME ZONE DEFAULT timestamp '2019-11-04 00:00:00 +01:02' NOT NULL,\n" +
            "    PRIMARY KEY (id)\n" +
            ")";
  1. Execute insert with generatedKeys return
var insert = "INSERT INTO EntityWithDefaultValues (id) VALUES (?)";
var options = new OraclePrepareOptions()
                    .setAutoGeneratedKeysIndexes(new JsonArray()
                            .add("string")
                            .add("localDate")
                            .add("localDateTime")
                            .add("inte")
                            .add("longe")
                            .add("floate")
                            .add("doublee")
                            .add("bigDecimal")
                            .add("offsetDateTime"));
// ...

Before the fix the localDate (and all other date columns) are not supported :

Caused by: java.sql.SQLException: Invalid column type
	at oracle.jdbc.driver.DateAccessor.getObject(DateAccessor.java:124)
	at oracle.jdbc.driver.T4CDateAccessor.getObject(T4CDateAccessor.java:645)
	at oracle.jdbc.driver.GeneratedStatement.getObject(GeneratedStatement.java:195)
	at oracle.jdbc.driver.GeneratedScrollableResultSet.getObject(GeneratedScrollableResultSet.java:333)
	at io.vertx.oracleclient.impl.commands.QueryCommand.decodeReturnedKeys(QueryCommand.java:246)

See the whole unit test here

A PR that fixes this bug is already available #1277

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions