org.h2.command.dml.Query.prepare()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(329)

本文整理了Java中org.h2.command.dml.Query.prepare方法的一些代码示例,展示了Query.prepare的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.prepare方法的具体详情如下:
包路径:org.h2.command.dml.Query
类名称:Query
方法名:prepare

Query.prepare介绍

[英]Prepare join batching.
[中]准备加入配料。

代码示例

代码示例来源:origin: com.h2database/h2

  1. /**
  2. * Optimize a query. This will remember the subquery info, clear it, prepare
  3. * the query, and reset the subquery info.
  4. *
  5. * @param query the query to prepare
  6. */
  7. public void optimizeQueryExpression(Query query) {
  8. // we have to hide current subQueryInfo if we are going to optimize
  9. // query expression
  10. SubQueryInfo tmp = subQueryInfo;
  11. subQueryInfo = null;
  12. preparingQueryExpression++;
  13. try {
  14. query.prepare();
  15. } finally {
  16. subQueryInfo = tmp;
  17. preparingQueryExpression--;
  18. }
  19. }

代码示例来源:origin: com.h2database/h2

  1. Query theQuery, String[] querySQLOutput) {
  2. List<Column> columnTemplateList = new ArrayList<>();
  3. theQuery.prepare();

代码示例来源:origin: com.h2database/h2

  1. query.prepare();
  2. if (query.getColumnCount() != columns.length) {
  3. throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);

代码示例来源:origin: com.h2database/h2

  1. left.prepare();
  2. right.prepare();
  3. int len = left.getColumnCount();

代码示例来源:origin: com.h2database/h2

  1. query.prepare();
  2. if (query.getColumnCount() != columns.length) {
  3. throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);

代码示例来源:origin: com.h2database/h2

  1. query.prepare();
  2. if (query.getColumnCount() != columns.length) {
  3. throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);

代码示例来源:origin: com.h2database/h2

  1. query.prepare();
  2. if (query.getColumnCount() != columns.length) {
  3. throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);

代码示例来源:origin: com.h2database/h2

  1. try {
  2. query = parseSelect();
  3. query.prepare();
  4. } finally {
  5. session.setParsingCreateView(false, viewName);

代码示例来源:origin: com.h2database/h2

  1. asQuery.prepare();
  2. if (data.columns.isEmpty()) {
  3. generateColumnsFromQuery();

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. public Expression optimize(Session session) throws SQLException {
  2. query.prepare();
  3. return this;
  4. }

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. public Expression optimize(Session session) throws SQLException {
  2. query.prepare();
  3. return this;
  4. }

代码示例来源:origin: com.eventsourcing/h2

  1. /**
  2. * Optimize a query. This will remember the subquery info, clear it, prepare
  3. * the query, and reset the subquery info.
  4. *
  5. * @param query the query to prepare
  6. */
  7. public void optimizeQueryExpression(Query query) {
  8. // we have to hide current subQueryInfo if we are going to optimize
  9. // query expression
  10. SubQueryInfo tmp = subQueryInfo;
  11. subQueryInfo = null;
  12. preparingQueryExpression++;
  13. try {
  14. query.prepare();
  15. } finally {
  16. subQueryInfo = tmp;
  17. preparingQueryExpression--;
  18. }
  19. }

代码示例来源:origin: org.wowtools/h2

  1. /**
  2. * Optimize a query. This will remember the subquery info, clear it, prepare
  3. * the query, and reset the subquery info.
  4. *
  5. * @param query the query to prepare
  6. */
  7. public void optimizeQueryExpression(Query query) {
  8. // we have to hide current subQueryInfo if we are going to optimize
  9. // query expression
  10. SubQueryInfo tmp = subQueryInfo;
  11. subQueryInfo = null;
  12. preparingQueryExpression++;
  13. try {
  14. query.prepare();
  15. } finally {
  16. subQueryInfo = tmp;
  17. preparingQueryExpression--;
  18. }
  19. }

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. public Expression optimize(Session session) throws SQLException {
  2. left = left.optimize(session);
  3. if (left == ValueExpression.NULL) {
  4. return left;
  5. }
  6. query.prepare();
  7. if (query.getColumnCount() != 1) {
  8. throw Message.getSQLException(ErrorCode.SUBQUERY_IS_NOT_SINGLE_COLUMN);
  9. }
  10. // Can not optimize IN(SELECT...): the data may change
  11. // However, could transform to an inner join
  12. return this;
  13. }

代码示例来源:origin: org.wowtools/h2

  1. query.prepare();
  2. if (query.getColumnCount() != columns.length) {
  3. throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);

代码示例来源:origin: org.wowtools/h2

  1. left.prepare();
  2. right.prepare();
  3. int len = left.getColumnCount();

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. private Query parserWith() throws SQLException {
  2. String tempViewName = readIdentifierWithSchema();
  3. Schema schema = getSchema();
  4. TableData recursiveTable;
  5. read("(");
  6. String[] cols = parseColumnList();
  7. ObjectArray columns = new ObjectArray();
  8. for (int i = 0; i < cols.length; i++) {
  9. columns.add(new Column(cols[i], Value.STRING));
  10. }
  11. int id = database.allocateObjectId(true, true);
  12. recursiveTable = schema.createTable(tempViewName, id, columns, false, false);
  13. recursiveTable.setTemporary(true);
  14. session.addLocalTempTable(recursiveTable);
  15. String querySQL = StringCache.getNew(sqlCommand.substring(parseIndex));
  16. read("AS");
  17. Query withQuery = parseSelect();
  18. withQuery.prepare();
  19. session.removeLocalTempTable(recursiveTable);
  20. id = database.allocateObjectId(true, true);
  21. TableView view = new TableView(schema, id, tempViewName, querySQL, null, cols, session, true);
  22. view.setTemporary(true);
  23. // view.setOnCommitDrop(true);
  24. session.addLocalTempTable(view);
  25. Query query = parseSelect();
  26. query.prepare();
  27. query.setPrepareAlways(true);
  28. // session.removeLocalTempTable(view);
  29. return query;
  30. }

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. public void prepare() throws SQLException {
  2. if (columns == null) {
  3. if (list.size() > 0 && ((Expression[]) list.get(0)).length == 0) {
  4. // special case where table is used as a sequence
  5. columns = new Column[0];
  6. } else {
  7. columns = table.getColumns();
  8. }
  9. }
  10. if (list.size() > 0) {
  11. for (int x = 0; x < list.size(); x++) {
  12. Expression[] expr = (Expression[]) list.get(x);
  13. if (expr.length != columns.length) {
  14. throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
  15. }
  16. for (int i = 0; i < expr.length; i++) {
  17. Expression e = expr[i];
  18. if (e != null) {
  19. expr[i] = e.optimize(session);
  20. }
  21. }
  22. }
  23. } else {
  24. query.prepare();
  25. if (query.getColumnCount() != columns.length) {
  26. throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
  27. }
  28. }
  29. }

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. public void prepare() throws SQLException {
  2. if (columns == null) {
  3. if (list.size() > 0 && ((Expression[]) list.get(0)).length == 0) {
  4. // special case where table is used as a sequence
  5. columns = new Column[0];
  6. } else {
  7. columns = table.getColumns();
  8. }
  9. }
  10. if (list.size() > 0) {
  11. for (int x = 0; x < list.size(); x++) {
  12. Expression[] expr = (Expression[]) list.get(x);
  13. if (expr.length != columns.length) {
  14. throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
  15. }
  16. for (int i = 0; i < expr.length; i++) {
  17. Expression e = expr[i];
  18. if (e != null) {
  19. expr[i] = e.optimize(session);
  20. }
  21. }
  22. }
  23. } else {
  24. query.prepare();
  25. if (query.getColumnCount() != columns.length) {
  26. throw Message.getSQLException(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
  27. }
  28. }
  29. }

代码示例来源:origin: com.h2database/com.springsource.org.h2

  1. private CreateView parseCreateView(boolean force) throws SQLException {
  2. boolean ifNotExists = readIfNoExists();
  3. String viewName = readIdentifierWithSchema();
  4. CreateView command = new CreateView(session, getSchema());
  5. this.prepared = command;
  6. command.setViewName(viewName);
  7. command.setIfNotExists(ifNotExists);
  8. command.setComment(readCommentIf());
  9. if (readIf("(")) {
  10. String[] cols = parseColumnList();
  11. command.setColumnNames(cols);
  12. }
  13. String select = StringCache.getNew(sqlCommand.substring(parseIndex));
  14. read("AS");
  15. try {
  16. Query query = parseSelect();
  17. query.prepare();
  18. command.setSelect(query);
  19. } catch (SQLException e) {
  20. if (force) {
  21. command.setSelectSQL(select);
  22. } else {
  23. throw e;
  24. }
  25. }
  26. return command;
  27. }

相关文章