Apache Empire-db: Difference between revisions

Content deleted Content added
m reword to avoid second person
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 52:
The corresponding Oracle syntax SQL statement is assumed to be as follows:
 
<sourcesyntaxhighlight lang="sql">
SELECT t1.EMPLOYEE_ID,
t1.LASTNAME || ', ' || t1.FIRSTNAME AS NAME,
Line 61:
AND t1.RETIRED=0
ORDER BY t1.LASTNAME, t1.FIRSTNAME
</syntaxhighlight>
</source>
 
This SQL statement can be created using Empire-db's command API using object model references like this:
 
<sourcesyntaxhighlight lang="java">
SampleDB db = getDatabase();
// Declare shortcuts (not necessary but convenient)
Line 84:
cmd.orderBy(EMP.LASTNAME);
cmd.orderBy(EMP.FIRSTNAME);
</syntaxhighlight>
</source>
 
In order to execute the query and retrieve a list of POJO's holding the query result the following code may be used:
 
<sourcesyntaxhighlight lang="java">
// Class definition for target objects
public class EmployeeInfo {
Line 108:
reader.close()
}
</syntaxhighlight>
</source>
 
Empire-db also supports field access through object references or obtaining query results as XML.