ingo@2360: package de.intevation.flys.model; ingo@2360: ingo@2360: import java.io.Serializable; ingo@2360: import java.math.BigDecimal; ingo@2360: import java.util.List; ingo@2360: ingo@2360: import javax.persistence.Column; ingo@2360: import javax.persistence.Entity; ingo@2360: import javax.persistence.Id; ingo@2360: import javax.persistence.JoinColumn; ingo@2360: import javax.persistence.OneToOne; ingo@2360: import javax.persistence.Table; ingo@2360: ingo@2360: import org.hibernate.Session; ingo@2360: import org.hibernate.Query; ingo@2360: import org.hibernate.annotations.Type; ingo@2360: ingo@2360: import com.vividsolutions.jts.geom.Point; ingo@2360: ingo@2360: import de.intevation.flys.backend.SessionHolder; ingo@2360: ingo@2360: ingo@2360: @Entity ingo@2360: @Table(name = "river_axes_km") ingo@2360: public class RiverAxisKm ingo@2360: implements Serializable ingo@2360: { ingo@2360: private Integer id; ingo@2360: private River river; ingo@2360: private BigDecimal km; ingo@2360: private Point geom; ingo@2360: ingo@2360: ingo@2360: public RiverAxisKm() { ingo@2360: } ingo@2360: ingo@2360: ingo@2360: @Id ingo@2360: @Column(name = "id") ingo@2360: public Integer getId() { ingo@2360: return id; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: public void setId(Integer id) { ingo@2360: this.id = id; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: @OneToOne ingo@2360: @JoinColumn(name = "river_id") ingo@2360: public River getRiver() { ingo@2360: return river; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: public void setRiver(River river) { ingo@2360: this.river = river; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: @Column(name = "km") ingo@2360: public BigDecimal getKm() { ingo@2360: return km; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: public void setKm(BigDecimal km) { ingo@2360: this.km = km; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: @Column(name = "geom") ingo@2360: @Type(type = "org.hibernatespatial.GeometryUserType") ingo@2360: public Point getGeom() { ingo@2360: return geom; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: public void setGeom(Point geom) { ingo@2360: this.geom = geom; ingo@2360: } ingo@2360: ingo@2360: ingo@2360: /** ingo@2360: * Returns a list of RiverAxisKm objects for a given river. ingo@2360: * ingo@2360: * @param riverid The ID of a river in the database. ingo@2360: * ingo@2360: * @return a list of RiverAxisKm objects. ingo@2360: */ ingo@2360: public static List getRiverAxisKms(int riverid) { ingo@2360: Session session = SessionHolder.HOLDER.get(); ingo@2360: ingo@2360: Query query = session.createQuery( ingo@2360: "from RiverAxisKm where river.id =:riverid"); ingo@2360: query.setParameter("riverid", riverid); ingo@2360: ingo@2360: List list = query.list(); ingo@2360: ingo@2360: return list; ingo@2360: } ingo@2360: } ingo@2360: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :