Skip to content

Commit 8738dea

Browse files
committed
Proofread
1 parent 46f5da6 commit 8738dea

2 files changed

Lines changed: 28 additions & 27 deletions

File tree

content/en/docs/howto/extensibility/howto-datastorage-api.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ The result is a generic OQL action that you can use in your microflows as follow
166166

167167
## Retrieving Objects Using OQL Specified in a Dataset
168168

169-
Instead of coding the OQL statement in a string parameter, you can also use a Dataset. This has the benefit the that Mendix Studio Pro will validate your OQL query.
169+
Instead of coding the OQL statement in a string parameter, you can also use a Dataset. This has the benefit that Mendix Studio Pro will validate your OQL query.
170170

171171
{{< figure src="/attachments/howto/extensibility/howto-datastorage-api/image040.png" class="no-border" >}}
172172

@@ -209,36 +209,35 @@ Below is the Java code to get the Dataset OQL, execute the OQL, and retrieve the
209209
return resultList;
210210
// END USER CODE
211211
}
212-
213212
```
214213

215214
## Retrieving Objects Using SQL
216215

217-
An API is available to allow you to execute SQL queries on the application database (this feature is currently in beta). Using this API, you can create a microflow action to execute SQL: similar to the action for OQL in the previous sections.
216+
You can use an API call to execute SQL queries on the application database (this feature is currently in beta). Using this call, you can create a microflow action to execute SQL: similar to the action for OQL in the previous sections.
218217

219218
The definition of the Java action resembles the OQL action, but instead of an OQL parameter you have an SQL parameter.
220219

221220
{{< figure src="/attachments/howto/extensibility/howto-datastorage-api/image025.png" class="no-border" >}}
222221

223-
The Java implementation below implements the following steps:
222+
The Java code below implements the following steps:
224223

225-
* Use *Core.dataStorage().executeWithConnection()* to execute some Java statements that receive a JDBC connection from the internal connection pool. This API is constructed to enable the Mendix Platform to guarantee that connections are returned to the pool after usage.
224+
* Use *Core.dataStorage().executeWithConnection()* to execute some Java statements that receive a JDBC connection from the internal connection pool. Using this call enables the Mendix Platform to guarantee that connections are returned to the pool after use.
226225

227-
```java
228-
@Override
229-
public java.util.List<IMendixObject> executeAction() throws Exception
230-
{
231-
// BEGIN USER CODE
232-
logger.info("executeAction: " + this.Sql);
233-
List<IMendixObject> resultList = null;
234-
resultList = Core.dataStorage().executeWithConnection(connection -> {...});
235-
return resultList;
236-
// END USER CODE
237-
}
238-
```
226+
```java
227+
@Override
228+
public java.util.List<IMendixObject> executeAction() throws Exception
229+
{
230+
// BEGIN USER CODE
231+
logger.info("executeAction: " + this.Sql);
232+
List<IMendixObject> resultList = null;
233+
resultList = Core.dataStorage().executeWithConnection(connection -> {...});
234+
return resultList;
235+
// END USER CODE
236+
}
237+
```
239238

240-
* With the JDBC connection you can now implement your Java as you would with a regular JDBC connection.
241-
* A prepared statement is created, executed and the resulting records are made available through a `ResultSet`.
239+
* With the JDBC connection you can now write your Java as you would with a regular JDBC connection.
240+
* A prepared statement is created, executed, and the resulting records are made available through a `ResultSet`.
242241

243242
```java
244243
resultList = Core.dataStorage().executeWithConnection(connection ->
@@ -250,7 +249,7 @@ The Java implementation below implements the following steps:
250249
ResultSetMetaData rmd = rset.getMetaData();
251250
int colCount = rmd.getColumnCount(); ```
252251

253-
* Next you loop through all the records in the `ResultSet` and create a Mendix object as specified by the user via ResultEntity.
252+
* Next you loop through all the records in the `ResultSet` and, for each record, create a Mendix object as specified by the user via ResultEntity.
254253

255254
```java
256255
while(rset.next()){
@@ -265,12 +264,12 @@ The Java implementation below implements the following steps:
265264

266265
You can find the complete Java source code in the *QueryApiBlogPost* GitHub repo on GitHub: [RetrieveAdvancedSQL](https://github.com/ako/QueryApiBlogPost/blob/master/javasource/hr/actions/RetrieveAdvancedSql.java).
267266

268-
You now have a generic SQL action that can be used in microflows to retrieve data from your application database. The query in this example returns the same data as the OQL earlier, so you can reuse the non-persistable entity DepartmentSummary as defined previously.
267+
You now have a generic SQL action that can be used in microflows to retrieve data from your application database. The query in this example returns the same data as the OQL earlier, so you can reuse the non-persistable entity **DepartmentSummary** as defined previously.
269268

270269
{{< figure src="/attachments/howto/extensibility/howto-datastorage-api/image029.png" class="no-border" >}}
271270

272-
{{% alert color="info" %}}
273-
Note that in case of SQL statements you need to implement security constraints yourself.
271+
{{% alert color="warning" %}}
272+
If you use SQL statements you need to implement security constraints yourself.
274273
{{% /alert %}}
275274

276275
## PostgreSQL-specific SQL
@@ -281,11 +280,11 @@ Using the JDBC connection you can benefit from vendor specific database extensio
281280
If you use vendor specific database functionality you will not be able to deploy your application seamlessly on other platforms and databases. Therefore, we advise you to use SQL only if you have no alternative way of implementing your requirements. In most cases you should be able to use OQL to achieve the same result, whilst keeping your application database independent.
282281
{{% /alert %}}
283282

284-
The following example illustrates the use of PostgreSQL-specific functionality. It serves as an example of how you can do this, but in this specific case an alternative solution, either using microflows or Java actions, is better as it would keep your application database independent.
283+
The following example illustrates the use of PostgreSQL-specific functionality. It serves as an example of how you can do this, but in this specific case an alternative solution, either using microflows or Java actions, would be better as it would keep your application database independent.
285284

286-
The requirement for this example is to generate a list of dates for all first Mondays of the month between a range specified by the user.
285+
The requirement for this example is to generate a list of dates for all the first Mondays of the month within a range specified by the user.
287286

288-
This example has a page where a user can enter a start and end date. The microflow triggered by the **Generate first Mondays of the month** button will print all the respective dates.
287+
This example has a page where an end-user can enter a start and end date. The microflow triggered by the **Generate first Mondays of the month** button will write all the respective dates to the log.
289288

290289
{{< figure src="/attachments/howto/extensibility/howto-datastorage-api/image031.png" class="no-border" >}}
291290

@@ -399,7 +398,7 @@ All the code is also available in [CreateDateRangeList.java](https://github.com/
399398
// END USER CODE
400399
```
401400

402-
When you use this in a microflow, you just need to specify the start and end dates, and the name of the resulting list. This example iterates through all the data objects in the list and prints the date of that object.
401+
When you use this in a microflow, you just need to specify the start and end dates, and the name of the resulting list. This example iterates through all the data objects in the list and writes the date of that object to the log.
403402

404403
{{< figure src="/attachments/howto/extensibility/howto-datastorage-api/image037.png" class="no-border" >}}
405404

content/en/docs/refguide/modeling/resources/data-sets/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ weight: 50
99

1010
A dataset is defined using either an [OQL query](/refguide/oql/) or a custom [Java action](/refguide/java-actions/). To constrain a dataset, parameters can be defined which can be used in the OQL query or Java action.
1111

12+
For one use of a dataset, see [Retrieving Objects Using OQL Specified in a Dataset](/howto/extensibility/howto-datastorage-api/#retrieving-objects-using-oql-specified-in-a-dataset) in *How to Use Mendix Data Storage APIs to Build Reusable Microflow Actions*.
13+
1214
## General
1315

1416
Fields for datasets contain the following properties:

0 commit comments

Comments
 (0)