Journal table auto-creation fails on Oracle
See original GitHub issueLagom Version
1.2.2, 1.3.0-RC2
API
Both
Library Dependencies
"com.oracle.jdbc" % "ojdbc7" % "12.1.0.2",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0"
Expected Behavior
Please describe the expected behavior of the issue, starting from the first action.
- Run a local Oracle 12c server and create a user named and identified by “chirp” with the ability to create tables (not for the faint of heart… talk to me if you’d like to try to reproduce)
- Check out the
jdbc-example-oracle
branch of https://github.com/TimMoore/activator-lagom-java-chirper-jdbc sbt runAll
Actual Behavior
These errors are logged at startup:
2017-02-20 17:16:26,885 [debug] chirp-impl-application-akka.actor.default-dispatcher-2 - c.l.l.i.p.j.SlickProvider - Creating table, executing: create table "journal" ("ordering" NUMBER(19) NOT NULL,"deleted" CHAR(1) DEFAULT 0 NOT NULL check ("deleted" in (0, 1)),"persistence_id" VARCHAR2(255) NOT NULL,"sequence_number" NUMBER(19) NOT NULL,"message" BLOB NOT NULL,"tags" VARCHAR2(255)); alter table "journal" add constraint "journal_pk" primary key("ordering","persistence_id","sequence_number"); create sequence "journal__ordering_seq" start with 1 increment by 1; create or replace trigger "journal__ordering_trg" before insert on "journal" referencing new as new for each row when (new."ordering" is null) begin select "journal__ordering_seq".nextval into :new."ordering" from sys.dual; end;
2017-02-20 17:16:27,245 [info] chirp-impl-application-akka.actor.default-dispatcher-3 - c.l.l.i.p.c.ClusterStartupTaskActor - Cluster start task cassandraOffsetStorePrepare done.
2017-02-20 17:16:27,337 [error] chirp-impl-application-akka.actor.default-dispatcher-3 - a.a.OneForOneStrategy - Missing IN or OUT parameter at index:: 1
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2076)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4790)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:4901)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5631)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java)
at com.lightbend.lagom.internal.persistence.jdbc.SlickProvider$$anonfun$com$lightbend$lagom$internal$persistence$jdbc$SlickProvider$$createTableInternal$1$$anonfun$apply$5.apply(SlickProvider.scala:137)
at com.lightbend.lagom.internal.persistence.jdbc.SlickProvider$$anonfun$com$lightbend$lagom$internal$persistence$jdbc$SlickProvider$$createTableInternal$1$$anonfun$apply$5.apply(SlickProvider.scala:136)
at slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)
The Slick 3.2.0 OracleProfile
class gives a hint about the problem:
Oracle throws an exception if you try to refer to a :new column in a trigger statement in a PreparedStatement. Since we need to create these statements for the AutoInc emulation, we execute all DDL statements with a non-prepared Statement.
However, Lagom does not take advantage of Slick’s workaround, because it extracts the statements generated by Slick and executes them itself here: https://github.com/lagom/lagom/blob/master/persistence-jdbc/core/src/main/scala/com/lightbend/lagom/internal/persistence/jdbc/SlickProvider.scala#L140
Reproducible Test Case
Reproduction is challenging. I used Oracle’s official Docker repository to get Oracle Database Standard Edition.
This was helpful for getting the JDBC drivers installed: http://stackoverflow.com/a/33883350/29470
Workaround
Create all tables manually and set lagom.persistence.jdbc.create-tables.auto = false
(requires Lagom 1.3.0 or the upcoming 1.2.3 because of #449).
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
I was able to get it working with manual table creation,
lagom.persistence.jdbc.create-tables.auto = false
and all of my SQL adjusted to work with Oracle.Looking closer this seems to be different, filed https://github.com/lagom/lagom/issues/3251