ingo@2363: package de.intevation.flys.model; ingo@2363: ingo@2363: import java.io.Serializable; ingo@2363: import java.util.List; ingo@2363: ingo@2363: import javax.persistence.Column; ingo@2363: import javax.persistence.Entity; ingo@2363: import javax.persistence.Id; ingo@2363: import javax.persistence.JoinColumn; ingo@2363: import javax.persistence.OneToOne; ingo@2363: import javax.persistence.Table; ingo@2363: ingo@2363: import org.hibernate.Session; ingo@2363: import org.hibernate.Query; ingo@2363: import org.hibernate.annotations.Type; ingo@2363: ingo@2363: import com.vividsolutions.jts.geom.LineString; ingo@2363: ingo@2363: import de.intevation.flys.backend.SessionHolder; ingo@2363: ingo@2363: ingo@2363: @Entity ingo@2363: @Table(name = "hws") ingo@2363: public class Hws ingo@2363: implements Serializable ingo@2363: { ingo@2363: private Integer id; ingo@2363: private String facility; ingo@2363: private String type; ingo@2363: private River river; ingo@2363: private LineString geom; ingo@2363: ingo@2363: public Hws() { ingo@2363: } ingo@2363: ingo@2363: ingo@2363: @Id ingo@2363: @Column(name = "id") ingo@2363: public Integer getId() { ingo@2363: return id; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public void setId(Integer id) { ingo@2363: this.id = id; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: @OneToOne ingo@2363: @JoinColumn(name = "river_id") ingo@2363: public River getRiver() { ingo@2363: return river; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public void setRiver(River river) { ingo@2363: this.river = river; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: @Column(name = "hws_facility") ingo@2363: public String getFacility() { ingo@2363: return facility; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public void setFacility(String facility) { ingo@2363: this.facility = facility; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: @Column(name = "type") ingo@2363: public String getType() { ingo@2363: return type; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public void setType(String type) { ingo@2363: this.type = type; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: @Column(name = "geom") ingo@2363: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@2363: public LineString getGeom() { ingo@2363: return geom; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public void setGeom(LineString geom) { ingo@2363: this.geom = geom; ingo@2363: } ingo@2363: ingo@2363: ingo@2363: public static List getHws(int riverId) { ingo@2363: Session session = SessionHolder.HOLDER.get(); ingo@2363: ingo@2363: Query query = session.createQuery( ingo@2363: "from Hws where river.id =:river_id"); ingo@2363: query.setParameter("river_id", riverId); ingo@2363: ingo@2363: return query.list(); ingo@2363: } ingo@2363: } ingo@2363: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :