Overview

Database converters transform one input data from a database (i.e. in JDBC format) into one output object. Once created, a converter might use stateful resources that must be released at the end of the conversion. Converters must comply to following Java interface signature:

public interface Converter<I, O> {
O convert(I data);
}

JDBC ResultSet to Java Converter

Deserialize a JDBC ResultSet into a Java Object. It processes just one row, and the table columns are mapped to object's fields.

PROPERTY

ID

DESCRIPTION


TYPE

REQUIRED

DEFAULT

EXAMPLE

Java class namemodelThe Java class name that will be used to map each row of the resultsetClassYes
com.datumize.examples.Customer
Convert Snake Casesnake-caseIndicated whether the columns names in the database tables are snake case or not. A column in snake case is represented as CUSTOMER_NAME, and will be converted into CustomerNamefor Java field mapping.Boolean
true

The following table represents a JDBC ResultSet as returned from a query.

select name, age, department, salary from employees;

#

full_name

age

department

salary

1Clint Good37Engineering42.000
2Eli Ugly42Management43.000
3Lee Bad35Sales55.000
4Ennio Musician51Operations21.000
5Sergio Virtuoso54Marketing42.000

This is the supporting Java class that will be used to convert; for the sake of simplicity, fields are declared public (bad practice). The Java class name will be com.datumize.examples.Employee

package com.datumize.examples;
  
public class Employee {
  public String name;
  public int age;
  public String department;
  public double salary;
  
  public Employee() {}
 
  public String toString() {
    return "[Employee: name=" + name + ", age=" + age + ", department=" + department + ", salary=" + salary + "]";
}
JAVA

If the row being processed is #3, the com.datumize.examples.Employee created object will look like this when toString() is printed out. 

[Employee: name=Lee Bad, age=35, department=Sales, salary=55000.0]


JDBC ResultSet to Map Converter

Deserialize a JDBC ResultSet into a Map. It processes just one row, and the map contains the column name as a map key, and the row value as the map value.

No properties are required.

The following table represents a JDBC ResultSet as returned from a query.

select name, age, department, salary from employees;

#

name

age

department

salary

1Clint Good37Engineering42.000
2Eli Ugly42Management43.000
3Lee Bad35Sales55.000
4Ennio Musician51Operations21.000
5Sergio Virtuoso54Marketing42.000

If the row being processed is #3, the java.util.Map created will look like this: 

key

value

nameLee Bad
age35
departmentSales
salary55.000