New ORM Framework for Kotlin

If you have an aversion to new frameworks, don't even read this. For other kind readers, please note that here I'm going to present a proposal for an API for modeling database queries in a declarative style with strong Kotlin type checking primarily. Only some classes around entities are implemented; the database connection is missing for now. In the project, I tried to evaluate my experience and vision so far. However, not all ideas presented in this paper are completely new. Some of them I drew from the Ujorm framework, and the entity concept was inspired by the Ktorm framework. But the code is new. The prototype results from a mosaic that has been slowly pieced together and has now taken a form that is hopefully worth presenting.

If you are not discouraged by the introduction, I will skip the general talk about ORM and let you get to the code samples. The demonstration examples use two relational database tables. This is an employee/department (unspecified organization) relationship where each employee may (or may not) have a supervisor. Both tables are described by entities from the following class diagram:

 Both tables are described by entities from the following class diagram.

Java HTML Report in a Few Lines of Code (Part 2)

In the previous article, I described the creation of an HTML table report with AJAX filtering and user sorting of columns — using a few lines of code written into a single Java command. For this, I used the ReportBuilder class from the Ujorm framework. Today, I’d like to show you how to place formatted content into the cells of such a table, as well as a few more improvements. What will the final table look like?

Our filter now has a new input field for limiting the number of displayed rows. We can insert the first column into our table, containing the sort order number of the row. The star classification of a hotel can be displayed using a list of appropriate characters with a tooltip, and the final column contains a link to the hotel home page. The original behaviour of the table remains the same, the updated source code is here:

A Simple AJAX Website in Java

During the Covid New Year of 2020, I created a simple prototype website using AJAX, with the goal of moving Java developers away from JavaScript and ideally also text-based HTML templates. The developer will however need to understand the structure of an HTML page as well as CSS selectors. I made my original solution a little more general, moved certain parts into the Ujorm framework, and am presenting the result here for your further inspiration.

For the prototype to make any sense, I created a web page for testing regular expressions. Let’s take a look at the code, worked into a regular Java servlet: