我对 Ebean 有一个奇怪的问题。
代码:
static <T> ImmutableMap<Long, T> getFromIdToItemMap(Iterable<SqlRow> rows,
Callable<Model.Finder<Long, T>> getFinder,
String idSqlFieldName,
Function<T, Long> getId) {
List<Long> tfzIds = Lists.newArrayList();
for (SqlRow i : rows) {
tfzIds.add((long) i.getLong(idSqlFieldName));
}
Builder<Long, T> id_to_tfz = new ImmutableMap.Builder<Long, T>();
List<T> tfzs;
try {
tfzs = getFinder.call().where().idIn(tfzIds).findList();
} catch (Exception e) {
throw new RuntimeException(e);
}
for (T tfz : tfzs) {
id_to_tfz.put(getId.apply(tfz), tfz);
}
return id_to_tfz.build();
}
例外:
javax.persistence.PersistenceException: Query threw SQLException:Parameter "#1" is not set; SQL statement:
select t0.virtuelle_adresse c0, t0.reale_adresse c1, t0.betr_nr c2, t0.bemerkung c3, t0.inbetriebnahme c4, t0.dekoder_typ_id c5, t0.model_tfz_typ_id c6, t0.eigentuemer_id c7
from tfz t0
where t0.virtuelle_adresse in (?) [90012-168]
Bind values:[]
Query was:
select t0.virtuelle_adresse c0, t0.reale_adresse c1, t0.betr_nr c2, t0.bemerkung c3, t0.inbetriebnahme c4, t0.dekoder_typ_id c5, t0.model_tfz_typ_id c6, t0.eigentuemer_id c7
from tfz t0
where t0.virtuelle_adresse in (?)
at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:815)
at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:795)
at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:210)
at com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:77)
at com.avaje.ebeaninternal.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:272)
at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1502)
at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:904)
at com.avaje.ebeaninternal.util.DefaultExpressionList.findList(DefaultExpressionList.java:177)
at controllers.Prognosis.getFromIdToItemMap(Prognosis.java:106)
... 26 more
Caused by: org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL statement:
select t0.virtuelle_adresse c0, t0.reale_adresse c1, t0.betr_nr c2, t0.bemerkung c3, t0.inbetriebnahme c4, t0.dekoder_typ_id c5, t0.model_tfz_typ_id c6, t0.eigentuemer_id c7
from tfz t0
where t0.virtuelle_adresse in (?) [90012-168]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.expression.Parameter.checkSet(Parameter.java:73)
at org.h2.command.Prepared.checkParameters(Prepared.java:163)
at org.h2.command.CommandContainer.query(CommandContainer.java:85)
at org.h2.command.Command.executeQuery(Command.java:191)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:109)
at com.jolbox.bonecp.PreparedStatementHandle.executeQuery(PreparedStatementHandle.java:172)
at com.avaje.ebeaninternal.server.query.CQuery.prepareBindExecuteQuery(CQuery.java:382)
at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:174)
... 32 more
我不明白 tfzIds 列表是如何没有插入到 EBean 构建的查询中的。
我尝试了什么:我将演员表添加到 long 以确保我不会在列表中得到空值。但这似乎不是问题所在,似乎根本没有阅读该列表。