package cz.cvut.fel.restauracefel.hibernate; // Generated 16.3.2009 21:36:54 by Hibernate Tools 3.2.1.GA import java.util.List; /** * UnitType generated by hbm2java */ public class UnitType extends DBEntity { private static final long serialVersionUID = -4350460631882330486L; private Integer unitTypeId; private String name; private String abbreviation; private Integer typeId; private int isDeleted; public UnitType() { } public UnitType(String name, String abbreviation, Integer typeId, int isDeleted) { this.name = name; this.abbreviation = abbreviation; this.typeId = typeId; this.isDeleted = isDeleted; } public Integer getUnitTypeId() { return this.unitTypeId; } public void setUnitTypeId(Integer unitTypeId) { this.unitTypeId = unitTypeId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getAbbreviation() { return this.abbreviation; } public void setAbbreviation(String abbreviation) { this.abbreviation = abbreviation; } public Integer getTypeId() { return typeId; } public void setTypeId(Integer typeId) { this.typeId = typeId; } public int getIsDeleted() { return isDeleted; } public void setIsDeleted(int isDeleted) { this.isDeleted = isDeleted; } public void create() { create(this); } public void delete() { delete(this); } public void update() { update(this); } public static UnitType findById(Integer id) { //return (UnitType) findById("UnitType", "unitTypeId", id); return (UnitType) findByIdNotDeleted("UnitType", "unitTypeId", id, "isDeleted", 0); } //vraci vsechny jednotky materialu, ktere nejsou oznaceny jako smazane public static List findAll(){ return findAllNotDeleted("UnitType", "isDeleted", 0); } public static UnitType findByName(String name) { //return (UnitType) findByStringName("UnitType", "name", name); return (UnitType) findByStringNameNotDeleted("UnitType", "name", name, "isDeleted", 0); } public static UnitType findByAbbreviation(String abbr) { //return (UnitType) findByStringName("UnitType", "abbreviation", abbr); return (UnitType) findByStringNameNotDeleted("UnitType", "abbreviation", abbr, "isDeleted", 0); } public static List findByTypeId(Integer typeId){ String query = "from UnitType ut where ut.typeId = :id1 and ut.isDeleted = :id2"; String[] paramNames = new String[] {"id1", "id2"}; String[] paramTypes = new String[] {"Integer", "Integer"}; Integer[] paramValues = new Integer[] {typeId, 0}; List res = executeQuery(query, paramNames, paramTypes, paramValues); if (res == null || res.isEmpty()) return null; return res; } }