1

using Esper engine - I find myself write lots of String SQLs, and do lots of string actions to insert query to EPStatement object.

What is the best practice to build queries in more convenient way? maybe build queries not with pure strings but with objects? (Have anyone used EPManagedStatement object?)

Eya
  • 2,183
  • 2
  • 12
  • 5

2 Answers2

1

There is also the Statement Object Model. With these classes you can build statements in a more object-oriented way and avoid all the string queries.

Taken from the documentation:

The statement object model is a set of classes that provide an object-oriented representation of an EPL or pattern statement. The object model classes are found in package com.espertech.esper.client.soda. An instance of EPStatementObjectModel represents a statement's object model.

The statement object model classes are a full and complete specification of a statement. All EPL and pattern constructs including expressions and sub-queries are available via the statement object model.

Community
  • 1
  • 1
Dario Seidl
  • 4,140
  • 1
  • 39
  • 55
-1

If you find that you are writing a lot of free-form EPL that only varies greatly by the actual values you are inserting, one approach you might find lightens up the amount of code is to use prepared statements ( (EPPreparedStatement). That way, you write the EPL once and then simply issue binds without having to re-specify the text all over again.

Nicholas
  • 15,916
  • 4
  • 42
  • 66