This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. CKG Edit ====== Class - Add a new attribute into a class ====== Sometimes we wonder how to add a property into a class. For example the property started into LongRunningTask. 1) First of all we add this property into class where we need it. Let's use our example: <code java>@Column(name = "task_started") private DateTime taskStarted;</code> Column annotation refers to database table column name (we do not have that column yet, but we will make it in third step). Also we need to add setters and getters. <code java>public void setTaskStarted(DateTime date){ taskStarted = date; } public DateTime getTaskStarted(){ return taskStarted; }</code> 2) Secondly we need to adjust Dto class as well. We do not need column annotation anymore: <code java>private DateTime taskStarted; public void setTaskStarted(DateTime date){ taskStarted = date; } public DateTime getTaskStarted(){ return taskStarted; }</code> 3) Before building our backend we need to adjust our table in database. We are using flyway script for adding some column into already existing table. We need to be careful with name, because its beginning number have to follow rules created before. So for our script we are using name: <code>V1_00_029__long-running-task-task-strated.sql</code> following <code>V1_00_028__eav-change-confidential-storage-key.sql</code> For our example: <code sql>ALTER TABLE idm_long_running_task ADD COLUMN task_started timestamp without time zone;</code> <note>It is necessary to follow these steps before building backend</note> In the end we only build backend and can start using our property. by poulm Log In