You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purpose of passing multiple primary keys to H2Data's with method is not clear. I thought it was to specify a composite primary key (for example, a combination of a hash key with a range key) but looks like it doesn't work.
For example, if I do:
new H2Data().with(
tableName,
new String[] {"hash", "range"},
new String[] {"attr"}
);
I get:
java.io.IOException: java.sql.SQLException: org.h2.jdbc.JdbcSQLException: Attempt to define a second primary key; SQL statement:
CREATE TABLE _89M6IUJQD5NL8RBG (hash VARCHAR PRIMARY KEY,range VARCHAR PRIMARY KEY,attr CLOB) [90017-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.setPrimaryKeyColumns(CreateTable.java:284)
at org.h2.command.ddl.CreateTable.addConstraintCommand(CreateTable.java:86)
at org.h2.command.Parser.parseCreateTable(Parser.java:6186)
at org.h2.command.Parser.parseCreate(Parser.java:4351)
at org.h2.command.Parser.parsePrepared(Parser.java:366)
at org.h2.command.Parser.parse(Parser.java:321)
at org.h2.command.Parser.parse(Parser.java:293)
at org.h2.command.Parser.prepareCommand(Parser.java:258)
at org.h2.engine.Session.prepareLocal(Session.java:578)
at org.h2.engine.Session.prepareCommand(Session.java:519)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
at com.jcabi.jdbc.Connect$Plain.open(Connect.java:75)
at com.jcabi.jdbc.JdbcSession.run(JdbcSession.java:375)
at com.jcabi.jdbc.JdbcSession.execute_aroundBody16(JdbcSession.java:328)
at com.jcabi.jdbc.JdbcSession$AjcClosure17.run(JdbcSession.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:213)
at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:140)
at com.jcabi.jdbc.JdbcSession.execute(JdbcSession.java:328)
at com.jcabi.dynamo.mock.H2Data.with_aroundBody10(H2Data.java:369)
at com.jcabi.dynamo.mock.H2Data$AjcClosure11.run(H2Data.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:213)
at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:140)
at com.jcabi.dynamo.mock.H2Data.with(H2Data.java:349)
at io.blizz.lib.test.impl.ReportEntryTest.createItem(ReportEntryTest.java:32)
which makes sense, because a table is supposed to have only one primary key.
The text was updated successfully, but these errors were encountered:
@pdacostaporto seems to be a bug/problem with H2. A table in SQL may have many columns as primary key, to my knowledge. Right? Maybe you can suggest a solution?
The purpose of passing multiple primary keys to
H2Data
'swith
method is not clear. I thought it was to specify a composite primary key (for example, a combination of a hash key with a range key) but looks like it doesn't work.For example, if I do:
I get:
which makes sense, because a table is supposed to have only one primary key.
The text was updated successfully, but these errors were encountered: