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