Search code examples
javaspeedment

Convert a SQL type into something else in Speedment


When Speedment generates entities from a database schema, is there some way to change the default type being generated? For an example, if I have a table like this:

create table comment (
    id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    author_name VARCHAR(40) NOT NULL,
    posted_date TIMESTAMP NOT NULL
);

By default Speedment will generate the TIMESTAMP column as java.sql.Timestamp. Can I make it so that TIMESTAMP columns are converted into Java long values instead?


Solution

  • In the Tool, select the "posted_date"-column on the left side and change the "Type Mapper" property to "Timestamp to Long". When you regenerate the code, then that column will be represented as a long instead.

    If you want to create a custom type mapper, there is a good tutorial for that on the Speedment GitHub page.