ingo@2809: package de.intevation.flys.model; ingo@2809: ingo@2809: import java.io.Serializable; ingo@2809: teichmann@5273: import java.util.List; teichmann@5273: ingo@2809: import javax.persistence.Entity; ingo@2809: import javax.persistence.Id; ingo@2809: import javax.persistence.Table; ingo@2809: import javax.persistence.GeneratedValue; ingo@2809: import javax.persistence.Column; ingo@2809: import javax.persistence.SequenceGenerator; ingo@2809: import javax.persistence.GenerationType; ingo@2809: ingo@2809: import org.apache.log4j.Logger; ingo@2809: teichmann@5273: import org.hibernate.Query; teichmann@5273: import org.hibernate.Session; teichmann@5273: teichmann@5273: import de.intevation.flys.backend.SessionHolder; ingo@2809: ingo@2809: @Entity ingo@2809: @Table(name = "bed_height_type") ingo@2809: public class BedHeightType ingo@2809: implements Serializable ingo@2809: { ingo@2809: private static Logger log = Logger.getLogger(BedHeightType.class); ingo@2809: ingo@2809: private Integer id; ingo@2809: private String name; ingo@2809: ingo@2809: ingo@2809: public BedHeightType() { ingo@2809: } ingo@2809: teichmann@5273: public BedHeightType(String name) { teichmann@5273: this.name = name; ingo@2809: } ingo@2809: ingo@2809: @Id ingo@2809: @SequenceGenerator( ingo@2809: name = "SEQUENCE_BED_HEIGHT_TYPE_ID_SEQ", ingo@2809: sequenceName = "BED_HEIGHT_TYPE_SEQ", ingo@2809: allocationSize = 1) ingo@2809: @GeneratedValue( ingo@2809: strategy = GenerationType.SEQUENCE, ingo@2809: generator = "SEQUENCE_BED_HEIGHT_TYPE_ID_SEQ") ingo@2809: @Column(name = "id") ingo@2809: public Integer getId() { ingo@2809: return id; ingo@2809: } ingo@2809: ingo@2809: public void setId(Integer id) { ingo@2809: this.id = id; ingo@2809: } ingo@2809: ingo@2809: @Column(name = "name") ingo@2809: public String getName() { ingo@2809: return name; ingo@2809: } ingo@2809: ingo@2809: public void setName(String name) { ingo@2809: this.name = name; ingo@2809: } ingo@2809: ingo@2809: teichmann@5273: public static BedHeightType fetchBedHeightTypeForType(String type) { teichmann@5273: Session session = SessionHolder.HOLDER.get(); teichmann@5273: Query query = session.createQuery( teichmann@5273: "from BedHeightType where type=:type"); teichmann@5273: teichmann@5273: query.setParameter("type", type); teichmann@5273: teichmann@5273: List results = query.list(); teichmann@5273: teichmann@5273: return results.isEmpty() ? null : (BedHeightType)results.get(0); ingo@2809: } ingo@2809: } ingo@2809: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :