I have an application that needs to model some existing DB tables (I cannot change them) with a number of duplicated rows. I'm trying to figure out a good design to reuse as much of the mapping code as possible so I don't have to duplicate a bunch of set calls.
Here is an example of two of the tables.
TIME_AND_EXPENSE_STAGING
Name Null Type
------------------ -------- --------------
SEQ_NUM NOT NULL NUMBER(31)
DATETIME_STAMP TIMESTAMP(6)
DEPT_ID NOT NULL VARCHAR2(10)
EMPL_ID NOT NULL VARCHAR2(11)
JOB_CODE NOT NULL VARCHAR2(6)
REGULAR_HRS NOT NULL NUMBER(4,2)
OVERTIME_HRS NOT NULL NUMBER(4,2)
MILES NOT NULL NUMBER(8,2)
COMMENTS VARCHAR2(4000)
TIME_AND_EXPENSE_APPROVED
Name Null Type
------------------ -------- --------------
SEQ_NUM NOT NULL NUMBER(31)
DATETIME_STAMP TIMESTAMP(6)
DEPT_ID NOT NULL VARCHAR2(10)
EMPL_ID NOT NULL VARCHAR2(11)
JOB_CODE NOT NULL VARCHAR2(6)
REGULAR_HRS NOT NULL NUMBER(4,2)
OVERTIME_HRS NOT NULL NUMBER(4,2)
MILES NOT NULL NUMBER(8,2)
COMMENTS VARCHAR2(4000)
APPROVE_TIME NOT NULL TIMESTAMP(6)
APPROVER_ID NOT NULL VARCHAR2(11)
I am using the Spring framework and the Spring RowMapper to populate the data objects. I feel like there should be some graceful way to use inheritance or polymorphism or some design pattern that will prevent me from having to copy and paste a bunch of set statements.
Please advise.