-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patheql.html
More file actions
417 lines (364 loc) · 13.4 KB
/
eql.html
File metadata and controls
417 lines (364 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!doctype html>
<html lang="en">
<head>
<title>Ebean ORM</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="/images/favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Source+Sans+Pro|Ubuntu&display=swap">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="/css/reset3.css">
<link rel="stylesheet" href="/css/site3.css">
<link rel="stylesheet" href="/css/pygments3.css">
</head>
<body>
<div id="main">
<div id="banner">
<header>
<nav id="top">
<h1 id="breadcrumb">
<a class="nav-logo" href="/"><img src="/images/logo-200.png" height="35"></a> <a href="/docs">Documentation</a><span class="sep"> / </span><a href="/docs/query/">Query</a><span class="sep"> / </span><span class="last">EQL</span>
</h1>
<ul>
<li><a onclick="toggleTheme();" title="switch dark light theme"><i class="fas fa-adjust"></i></a></li>
</ul>
</nav>
</header>
</div>
<div class="grid grid-docs">
<aside>
<nav class="side">
<ul>
<li class="nav0 ">
<a href="/docs/getting-started">Getting started</a>
</li>
<li class="nav0 ">
<a href="/docs/intro">Introduction</a>
</li>
<li class="nav0 active">
<a class="active" href="/docs">Documentation</a>
<ul>
<li class="nav1 ">
<a href="/docs/agents">AI Agents</a>
</li>
<li class="nav1 ">
<a href="/docs/best-practice">Best practice</a>
</li>
<li class="nav1 active">
<a class="active" href="/docs/query">Query</a>
<ul class="nav">
<li >
<a href="/docs/query/query-beans">Query beans</a>
</li>
<li >
<a href="/docs/query/where">Where</a>
</li>
<li >
<a href="/docs/query/expressions">Expressions</a>
</li>
<li >
<a href="/docs/query/orderBy">OrderBy</a>
</li>
<li >
<a href="/docs/query/select">Select</a>
</li>
<li >
<a href="/docs/query/fetch">Fetch</a>
</li>
<li >
<a href="/docs/query/fetchgroup">FetchGroup</a>
</li>
<li >
<a href="/docs/query/filterMany">FilterMany</a>
</li>
<li >
<a href="/docs/query/aggregation">Aggregation</a>
</li>
<li >
<a href="/docs/query/having">Having</a>
</li>
<li >
<a href="/docs/query/native-sql">Native Sql</a>
</li>
<li >
<a href="/docs/query/rawSql">RawSql</a>
</li>
<li >
<a href="/docs/query/update">Update query</a>
</li>
<li >
<a href="/docs/query/delete">Delete query</a>
</li>
<li >
<a href="/docs/query/dtoquery">DtoQuery</a>
</li>
<li >
<a href="/docs/query/sqlquery">SqlQuery</a>
</li>
<li >
<a href="/docs/query/sqlupdate">SqlUpdate</a>
</li>
<li >
<a href="/docs/query/callablesql">CallableSql</a>
</li>
</ul>
</li>
<li class="nav1 ">
<a href="/docs/persist">Persist</a>
</li>
<li class="nav1 ">
<a href="/docs/transactions">Transactions</a>
</li>
<li class="nav1 ">
<a href="/docs/mapping">Mapping</a>
</li>
<li class="nav1 ">
<a href="/docs/ddl-generation">DDL & Migrations</a>
</li>
<li class="nav1 ">
<a href="/docs/logging">Logging</a>
</li>
<li class="nav1 ">
<a href="/docs/testing">Testing</a>
</li>
<li class="nav1 ">
<a href="/docs/read-replicas">Read Replicas</a>
</li>
<li class="nav1 ">
<a href="/docs/database">Database platforms</a>
</li>
<li class="nav1 ">
<a href="/docs/multi-database">Multiple databases</a>
</li>
<li class="nav1 ">
<a href="/docs/kotlin">Kotlin</a>
</li>
<li><a href="/docs/tuning">Tuning</a></li>
<li class="nav1 ">
<a href="/docs/features">Features</a>
</li>
</ul>
</li>
<li class="nav0 ">
<a href="/support">Getting help</a>
</li>
<li class="nav0 ">
<a target="_blank" href="/apidoc/13">API Javadoc</a>
</li>
<li class="nav0 ">
<a href="/videos">Videos</a>
</li>
<li class="nav0 ">
<a href="/docs/upgrading">Upgrading</a>
</li>
<li class="nav0 ">
<a href="/docs/deprecated">Deprecated</a>
</li>
<li class="nav0 ">
<a href="/releases">Releases</a>
</li>
</ul>
</nav>
</aside>
<article>
<form action="https://www.google.com/search" method="get" class="inline-form">
<input type="hidden" name="as_sitesearch" value="ebean.io">
<div id="page-search">
<div class="input-group">
<input class="frm" name="q" id="searchinput" type="text" placeholder="Search... (press 's' to focus)" data-placeholder-focus="Search... (use '↑', '↓' and '⏎' to select results)" data-placeholder-blur="Search... (press 's' to focus)" autocomplete="off">
<div class="input-group-btn">
<button class="frm" type="submit"><i class="fas fa-search"></i></button>
</div>
</div>
<div id="page-search-results" style="display: none;">
<ul id="search-results-container" class="search-results"><li class=" active"><a href="/docs" title="Docs"><span style="color:#777;">Docs</span> Documentation </a></li><li class=""><small style="color:#999;">And 101 more...</small></li></ul>
</div>
</div>
</form>
<div class="bs-docs-section">
<h2 id="eql">Ebean Query Language (EQL)</h2>
<div class="alert alert-danger">
<strong>⚠️ Ebean 16.x only:</strong> Ebean Query Language (EQL) was removed in Ebean 17.x.
If you are using Ebean 17.x, use <a href="/docs/query/query-beans">Query Beans</a> (recommended) or the
<a href="/docs/query/where">standard Query API</a> instead.
See <a href="/docs/upgrading">Upgrading from 16.x to 17.x</a> for migration examples.
</div>
<h3 id="overview">Overview</h3>
<p>
Ebean Query Language (EQL) was a SQL-like query language available in Ebean 16.x releases that allowed
you to write queries using a string-based syntax similar to SQL. EQL queries were parsed early and
converted to type-safe Query objects that could be further modified before execution.
</p>
<p>
EQL has been removed in Ebean 17.x in favor of more type-safe approaches using
<a href="/docs/query/query-beans">Query Beans</a> (recommended) and the
<a href="/docs/query/where">standard Query API</a>.
</p>
<h3 id="syntax">EQL Syntax (16.x reference)</h3>
<p>
This section documents EQL syntax for reference if you are maintaining an Ebean 16.x application.
</p>
<h4>Basic Structure</h4>
<p>EQL queries followed this basic pattern:</p>
<pre><code>
find [selected-properties]
[fetch property-paths]
where [predicates]
order by [order-by-clause]
limit [limit-clause]
</code></pre>
<h4>Complete Example (16.x)</h4>
<pre><code class="language-java">
String eql = " where customer.name like :custName " +
" and orderDate > :minOrderDate " +
" order by id desc " +
" limit 50 ";
List<Order> orders = DB.createQuery(Order.class, eql)
.setParameter("custName", "Rob%")
.setParameter("minOrderDate", lastWeek)
.findList();
</code></pre>
<h4>WHERE Clause</h4>
<p>The where clause contained predicates using property paths:</p>
<pre><code class="language-java">
"where customer.name like :custName" // string comparison
"where status = :status" // property equals
"where orderDate > :date" // date comparison
"where amount between :min and :max" // range check
"where customer.id in :customerIds" // IN clause
"where items.size > 0" // collection check
</code></pre>
<h4>ORDER BY Clause</h4>
<pre><code class="language-java">
"order by id" // ascending
"order by id desc" // descending
"order by customer.id, id desc" // multiple properties
</code></pre>
<h4>SELECT and FETCH</h4>
<pre><code class="language-java">
// Select specific properties from root entity
"select (name, email) where status = :status"
// Fetch properties from related entities
"fetch customer (id, name) where status = :status"
"fetch customer.address (city, country) fetch items where ..."
// Named query definition
@NamedQuery(
name="bugStatus",
query="fetch loggedBugs where loggedBugs.status = :bugStatus order by name"
)
</code></pre>
<h3 id="limitations">Why EQL Was Removed</h3>
<ul>
<li><strong>Lack of type safety:</strong> Query strings are error-prone and can only be validated at runtime</li>
<li><strong>No IDE support:</strong> String-based syntax does not benefit from IDE auto-completion or refactoring</li>
<li><strong>Maintenance burden:</strong> Maintaining a custom query parser was resource-intensive</li>
<li><strong>Better alternatives:</strong> Query Beans provide the same functionality with compile-time safety</li>
<li><strong>Industry trend:</strong> Modern ORMs favor type-safe query builders</li>
</ul>
<h3 id="migration">Migrating from EQL to 17.x</h3>
<p>See <a href="/docs/upgrading">Upgrading from 16.x to 17.x</a> for detailed migration examples converting EQL queries to:</p>
<ul>
<li><strong>Query Beans (Recommended)</strong> - Type-safe, compile-time checking, IDE auto-completion</li>
<li><strong>Standard Query API</strong> - Fluent API using method calls</li>
<li><strong>Raw SQL / SqlQuery</strong> - For complex database-specific queries</li>
</ul>
<h4>Quick Migration Example</h4>
<p><strong>EQL (16.x):</strong></p>
<pre><code class="language-java">
String eql = "where customer.name like :custName and orderDate > :minOrderDate " +
"order by id desc limit 50";
List<Order> orders = DB.createQuery(Order.class, eql)
.setParameter("custName", "Rob%")
.setParameter("minOrderDate", lastWeek)
.findList();
</code></pre>
<p><strong>Query Beans (17.x - Recommended):</strong></p>
<pre><code class="language-java">
List<Order> orders = new QOrder()
.customer.name.contains("Rob")
.orderDate.greaterThan(lastWeek)
.orderBy().id.desc()
.setMaxRows(50)
.findList();
</code></pre>
<p><strong>Standard Query API (17.x - Alternative):</strong></p>
<pre><code class="language-java">
List<Order> orders = DB.find(Order.class)
.where()
.contains("customer.name", "Rob")
.gt("orderDate", lastWeek)
.order().desc("id")
.setMaxRows(50)
.findList();
</code></pre>
<h3 id="named-queries">Named Queries (16.x)</h3>
<p>
Named Queries in Ebean 16.x used EQL syntax defined in <code>@NamedQuery</code> annotations.
In Ebean 17.x, Named Queries still exist but the EQL syntax within them is no longer actively used.
</p>
<p><strong>16.x Named Query Definition:</strong></p>
<pre><code class="language-java">
@NamedQueries(value={
@NamedQuery(
name="bugsSummary",
query="find (name, email) fetch loggedBugs (title, status) where id=:id "),
@NamedQuery(
name="bugStatus",
query="fetch loggedBugs where loggedBugs.status = :bugStatus order by name")
})
@Entity
public class User {
...
}
</code></pre>
<p><strong>16.x Named Query Execution:</strong></p>
<pre><code class="language-java">
User user = DB.createNamedQuery(User.class, "bugsSummary")
.setParameter("id", 1)
.findOne();
</code></pre>
<p><strong>17.x Alternative:</strong> Use Query Beans or standard Query API directly instead of Named Queries.</p>
<h3 id="resources">Resources</h3>
<ul>
<li><a href="/docs/query/query-beans">Query Beans Documentation</a> - Type-safe query alternative</li>
<li><a href="/docs/query/where">Where Clause Documentation</a> - Standard Query API for predicates</li>
<li><a href="/docs/upgrading">Upgrading from 16.x to 17.x</a> - Detailed migration guide</li>
<li><a href="/docs/query">Query Documentation Index</a> - All query methods and options</li>
</ul>
<h3 id="troubleshooting">Troubleshooting</h3>
<h4>Q: I see "DB.createQuery() no longer accepts an EQL query string" error</h4>
<p>
<strong>A:</strong> You are using Ebean 17.x which removed EQL support. The method <code>DB.createQuery(Class, eqlString)</code>
no longer exists. Use one of these alternatives:
</p>
<ol>
<li><strong>Query Beans (recommended):</strong> <code>new QCustomer().name.eq("Rob").findOne()</code></li>
<li><strong>Standard Query API:</strong> <code>DB.find(Customer.class).where().eq("name", "Rob").findOne()</code></li>
<li><strong>Raw SQL:</strong> <code>DB.findNative(Customer.class, sqlString)</code></li>
</ol>
<h4>Q: Can I still use Ebean 16.x with EQL?</h4>
<p>
<strong>A:</strong> Yes, Ebean 16.x continues to receive maintenance updates. See
<a href="https://github.com/ebean-orm/ebean/releases">releases</a> for available 16.x versions.
</p>
<h4>Q: Where can I find more migration help?</h4>
<p>
<strong>A:</strong> See the <a href="/docs/upgrading">Upgrading from 16.x to 17.x</a> guide for detailed examples
and migration strategies.
</p>
</div>
</article>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="/js/site3.js"></script>
<script src="/js/search3.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-75181644-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-75181644-1');
</script>
</body>
</html>