StorIO database query

However, what goes inside the .onExceptionResumeNext(...) call? Basically, we need to query the database using StorIO. The query is created by calling the following:

StorIOFactory.get(this)
.get()
.listOfObjects(StockUpdate.class)
.withQuery(Query.builder()
.table(StockUpdateTable.TABLE)
.orderBy("date DESC")
.limit(50)
.build())
.prepare()

Let's go line by line to see what this code does. The following line, which is the first line, instructs StorIO to start building a SELECT query:

.get()

The following line specifies what kind of type objects will be returned:

.listOfObjects(StockUpdate.class)

This call is basically used to select the appropriate mapper (GetResolver) to do a mapping from the SELECT query columns to domain objects.

The following line will start the building of the SELECT query that will be used to retrieve data:

.withQuery(Query.builder()

So the next line shows which table will be used:

.table(StockUpdateTable.TABLE)

Along with these lines that specify that we want entries retrieved in descending order by the date column and that the results should be limited to 50 entries:

.orderBy("date DESC")
.limit(50)

This line returns the Query object:

.build())

The following line lets the StorIO know that we are done configuring the StorIO and the query:

.prepare()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.153