Look-up Tables: Entity beans (cont)
26 January 2009Now that we have refactored the LookupTable bean, it’s time to do the same with the LookupTableProperty and the LookupTableEntry. Since we created a new, numeric key for the LookupTable, the only change that we really have to make to the LookupTableProperty will be to change its tableId foreign key property from a String to an int:
package org.restafarian.core.beans;
/**
* <p>This entity bean defines a single look-up table property.</p>
*/
public class LookupTableProperty extends PersistentBeanBase {
private static final long serialVersionUID = 1;
private int id = -1;
private int tableId = 0;
private int sequence = 0;
private boolean inputRequired = false;
private boolean displayOnList = false;
private String name = null;
private String type = null;
private String size = null;
private String label = null;
private String colHeading = null;
private String source = null;
private String notes = null;
public String getColHeading() {
return colHeading;
}
public void setColHeading(String colHeading) {
this.colHeading = colHeading;
}
public boolean isDisplayOnList() {
return displayOnList;
}
public void setDisplayOnList(boolean displayOnList) {
this.displayOnList = displayOnList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public boolean isInputRequired() {
return inputRequired;
}
public void setInputRequired(boolean inputRequired) {
this.inputRequired = inputRequired;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public int getSequence() {
return sequence;
}
public void setSequence(int sequence) {
this.sequence = sequence;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public int getTableId() {
return tableId;
}
public void setTableId(int tableId) {
this.tableId = tableId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
This doesn’t require any changes to the Hibernate mapping or the Betwixt mapping, which is not the case with the LookupTableEntry, where we need to add a new property for the context:
package org.restafarian.core.beans;
/**
* <p>This entity bean defines a single look-up table entry.</p>
*/
public class LookupTableEntry extends PersistentBeanBase {
private static final long serialVersionUID = 1;
private int id = -1;
private String context = null;
private String tableName = null;
private String entryId = null;
private String description = null;
private String[] property = new String[20];
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getEntryId() {
return entryId;
}
public void setEntryId(String entryId) {
this.entryId = entryId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getProperty(int i) {
return property[i];
}
public void setProperty(int i, String property) {
this.property[i] = property;
}
public String getProperty00() {
return property[0];
}
public void setProperty00(String property00) {
this.property[0] = property00;
}
public String getProperty01() {
return property[1];
}
public void setProperty01(String property01) {
this.property[1] = property01;
}
public String getProperty02() {
return property[2];
}
public void setProperty02(String property02) {
this.property[2] = property02;
}
public String getProperty03() {
return property[3];
}
public void setProperty03(String property03) {
this.property[3] = property03;
}
public String getProperty04() {
return property[4];
}
public void setProperty04(String property04) {
this.property[4] = property04;
}
public String getProperty05() {
return property[5];
}
public void setProperty05(String property05) {
this.property[5] = property05;
}
public String getProperty06() {
return property[6];
}
public void setProperty06(String property06) {
this.property[6] = property06;
}
public String getProperty07() {
return property[7];
}
public void setProperty07(String property07) {
this.property[7] = property07;
}
public String getProperty08() {
return property[8];
}
public void setProperty08(String property08) {
this.property[8] = property08;
}
public String getProperty09() {
return property[9];
}
public void setProperty09(String property09) {
this.property[9] = property09;
}
public String getProperty10() {
return property[10];
}
public void setProperty10(String property10) {
this.property[10] = property10;
}
public String getProperty11() {
return property[11];
}
public void setProperty11(String property11) {
this.property[11] = property11;
}
public String getProperty12() {
return property[12];
}
public void setProperty12(String property12) {
this.property[12] = property12;
}
public String getProperty13() {
return property[13];
}
public void setProperty13(String property13) {
this.property[13] = property13;
}
public String getProperty14() {
return property[14];
}
public void setProperty14(String property14) {
this.property[14] = property14;
}
public String getProperty15() {
return property[15];
}
public void setProperty15(String property15) {
this.property[15] = property15;
}
public String getProperty16() {
return property[16];
}
public void setProperty16(String property16) {
this.property[16] = property16;
}
public String getProperty17() {
return property[17];
}
public void setProperty17(String property17) {
this.property[17] = property17;
}
public String getProperty18() {
return property[18];
}
public void setProperty18(String property18) {
this.property[18] = property18;
}
public String getProperty19() {
return property[19];
}
public void setProperty19(String property19) {
this.property[19] = property19;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
}
The context property also needs to be added to the Hibernate mapping:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.restafarian.core.beans.LookupTableEntry" table="lookuptableentry">
<id name="id" unsaved-value="-1">
<generator class="native"/>
</id>
<property name="context"/>
<property name="tableName"/>
<property name="entryId"/>
<property name="description"/>
<property name="property00"/>
<property name="property01"/>
<property name="property02"/>
<property name="property03"/>
<property name="property04"/>
<property name="property05"/>
<property name="property06"/>
<property name="property07"/>
<property name="property08"/>
<property name="property09"/>
<property name="property10"/>
<property name="property11"/>
<property name="property12"/>
<property name="property13"/>
<property name="property14"/>
<property name="property15"/>
<property name="property16"/>
<property name="property17"/>
<property name="property18"/>
<property name="property19"/>
<property name="creationDate"/>
<property name="createdBy"/>
<property name="lastUpdate"/>
<property name="lastUpdateBy"/>
</class>
</hibernate-mapping>
… as well as the Betwixt mapping:
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
<element name='entry'>
<attribute name='context' property='context'/>
<attribute name='tableName' property='tableName'/>
<attribute name='entryId' property='entryId'/>
<element name='description' property = 'description'/>
<element name='property00' property = 'property00'/>
<element name='property01' property = 'property01'/>
<element name='property02' property = 'property02'/>
<element name='property03' property = 'property03'/>
<element name='property04' property = 'property04'/>
<element name='property05' property = 'property05'/>
<element name='property06' property = 'property06'/>
<element name='property07' property = 'property07'/>
<element name='property08' property = 'property08'/>
<element name='property09' property = 'property09'/>
<element name='property10' property = 'property10'/>
<element name='property11' property = 'property11'/>
<element name='property12' property = 'property12'/>
<element name='property13' property = 'property13'/>
<element name='property14' property = 'property14'/>
<element name='property15' property = 'property15'/>
<element name='property16' property = 'property16'/>
<element name='property17' property = 'property17'/>
<element name='property18' property = 'property18'/>
<element name='property19' property = 'property19'/>
<element name='creationDate' property='creationDate'/>
<element name='createdBy' property='createdBy'/>
<element name='lastUpdate' property='lastUpdate'/>
<element name='lastUpdateBy' property='lastUpdateBy'/>
</element>
</info>
That takes care of all of the entity beans. Next we’ll refactor the DAOs, which seems to be something I’m doing a lot these days!
Leave a reply
You must be logged in to post a comment.





