Skip to content

SQLP 2.4.0 and SQLEP 1.9.4 Tutorial

Vladimír Hudec edited this page Jan 27, 2015 · 8 revisions

###The tutorial is updated for SQLP 2.4.0+ and SQLEP 1.9.4+

###Introduction The new feature of the SQL Processor Eclipse Plugin (SQLEP) version 1.9.4 is the new control directive enum-for-check-constraints. It can help to reduce the number of generated enumerations. The enumerations are generated based on DB column constraints. The usage is described in SQLP 2.2.0 and SQLEP 1.6 Tut..

It can be, the DB column constraints are the same with the exception they are defined on different tables and/or columns. For example we have the HSQLDB layout

CREATE TABLE PERSON
(
....
GENDER VARCHAR(1) NOT NULL
....
);

ALTER TABLE PERSON ADD CONSTRAINT CHECK_PERSON_GENDER
    CHECK (GENDER IN ('M', 'F', '0'))
;

CREATE TABLE CONTACT
(
... 
GENDER2 VARCHAR(1)
...
);
ALTER TABLE CONTACT ADD CONSTRAINT CHECK_CONTACT_GENDER2
    CHECK (GENDER2 IN ('M', 'F', '0'))
;

The standard SQLEP output is to have 2 generated enumerations PersonGender and ContactGender2. To reduce the number of enumerations to one and name it Gender, we can use

pojogen-enum-for-check-constraints Gender PERSON_GENDER CONTACT_GENDER2;

The first parameter Gender is the name of the final enumeration. Next there's a list of all DB column constraints, which have the same effective definitions. Ctrl-SPACE invoked content assist can help to find the correct DB column constraint.

Clone this wiki locally