sormula | simple (easy) object relational mapping | |
|
Schema and Java class used by SimpleExample.java. CREATE TABLE INVENTORY
(
PARTNUMBER INTEGER,
QUANTITY INTEGER,
MANFID VARCHAR(40)
)
import org.sormula.annotation.Column; import org.sormula.annotation.Where; /** * Class that corresponds to a row in the INVENTORY table. * * @author Jeff Miller */ @Wheres({ @Where(name="manf", fieldNames="manufacturerId"), // where manf=? @Where(name="partNumberIn", whereFields=@WhereField(name="partNumber", comparisonOperator="IN")) // where partnumber in (?, ?, ...) }) // table name defaults to "inventory", use @Row(tableName="...") to override public class Inventory { // column name defaults to "partnumber", column is primary key @Column(primaryKey=true) int partNumber; // no annotation is needed when field name is same as column name int quantity; // column name is "manfid" @Column(name="manfid") String manufacturerId; public int getPartNumber() { return partNumber; } public void setPartNumber(int partNumber) { this.partNumber = partNumber; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public String getManufacturerId() { return manufacturerId; } public void setManufacturerId(String manufacturerId) { this.manufacturerId = manufacturerId; } } |
|
© 2018 Sormula, LLC |