diff --git a/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java b/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java index bd4e63184..d7d3f6675 100644 --- a/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java +++ b/dao-impl/ebean-dao/src/main/java/com/linkedin/metadata/dao/EbeanLocalDAO.java @@ -30,8 +30,6 @@ import io.ebean.ExpressionList; import io.ebean.PagedList; import io.ebean.Query; -import io.ebean.RawSql; -import io.ebean.RawSqlBuilder; import io.ebean.Transaction; import io.ebean.config.ServerConfig; import io.ebean.datasource.DataSourceConfig; @@ -512,19 +510,15 @@ private List batchGet(@Nonnull Set outputParamsToValues) { - final String urnArg = "urn" + selectId; - final String aspectArg = "aspect" + selectId; - final String versionArg = "version" + selectId; + private String batchGetSelect(@Nonnull String urn, @Nonnull String aspect, long version, + @Nonnull List outputParams) { + outputParams.add(urn); + outputParams.add(aspect); + outputParams.add(version); - outputParamsToValues.put(urnArg, urn); - outputParamsToValues.put(aspectArg, aspect); - outputParamsToValues.put(versionArg, version); - - return String.format("SELECT urn, aspect, version, metadata, createdOn, createdBy, createdFor " - + "FROM %s WHERE urn = :%s AND aspect = :%s AND version = :%s", - EbeanMetadataAspect.class.getAnnotation(Table.class).name(), urnArg, aspectArg, versionArg); + return String.format("SELECT t.urn, t.aspect, t.version, t.metadata, t.createdOn, t.createdBy, t.createdFor " + + "FROM %s t WHERE urn = ? AND aspect = ? AND version = ?", + EbeanMetadataAspect.class.getAnnotation(Table.class).name()); } @Nonnull @@ -542,9 +536,9 @@ private List batchGetUnion(@Nonnull List params = new HashMap<>(); + final List params = new ArrayList<>(); for (int index = position; index < end; index++) { - sb.append(batchGetSelect(index - position, keys.get(index).getUrn().toString(), + sb.append(batchGetSelect(keys.get(index).getUrn().toString(), ModelUtils.getAspectName(keys.get(index).getAspectClass()), keys.get(index).getVersion(), params)); if (index != end - 1) { @@ -552,16 +546,10 @@ private List batchGetUnion(@Nonnull List query = _server.find(EbeanMetadataAspect.class).setRawSql(rawSql); + final Query query = _server.findNative(EbeanMetadataAspect.class, sb.toString()); - for (Map.Entry param : params.entrySet()) { - query.setParameter(param.getKey(), param.getValue()); + for (int i = 1; i <= params.size(); i++) { + query.setParameter(i, params.get(i - 1)); } return query.findList();