ingo@2825: package de.intevation.flys.model; ingo@2825: teichmann@5323: import de.intevation.flys.backend.SessionHolder; teichmann@5323: ingo@2825: import java.io.Serializable; teichmann@5323: ingo@2825: import java.util.List; ingo@2825: teichmann@5323: import javax.persistence.Column; ingo@2825: import javax.persistence.Entity; teichmann@5323: import javax.persistence.GeneratedValue; teichmann@5323: import javax.persistence.GenerationType; ingo@2825: import javax.persistence.Id; ingo@2825: import javax.persistence.JoinColumn; ingo@2825: import javax.persistence.OneToOne; teichmann@5323: import javax.persistence.SequenceGenerator; teichmann@5323: import javax.persistence.Table; ingo@2871: ingo@2825: import org.apache.log4j.Logger; ingo@2825: teichmann@5323: import org.hibernate.Query; teichmann@5323: import org.hibernate.Session; ingo@2871: ingo@2825: ingo@2825: @Entity ingo@2825: @Table(name = "flow_velocity_model") ingo@2825: public class FlowVelocityModel ingo@2825: implements Serializable ingo@2825: { ingo@2825: private static Logger logger = Logger.getLogger(FlowVelocityModel.class); ingo@2825: ingo@2825: ingo@2825: private Integer id; ingo@2825: ingo@2825: private DischargeZone dischargeZone; ingo@2825: ingo@2825: private String description; ingo@2825: ingo@2825: ingo@2825: public FlowVelocityModel() { ingo@2825: } ingo@2825: ingo@2825: teichmann@5323: public FlowVelocityModel(DischargeZone dischargeZone) { teichmann@5323: this(dischargeZone, null); ingo@2825: } ingo@2825: ingo@2825: ingo@2825: public FlowVelocityModel( ingo@2825: DischargeZone dischargeZone, ingo@2825: String description ingo@2825: ) { ingo@2825: this.dischargeZone = dischargeZone; ingo@2825: this.description = description; ingo@2825: } ingo@2825: ingo@2825: @Id ingo@2825: @SequenceGenerator( ingo@2825: name = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ", ingo@2825: sequenceName = "FLOW_VELOCITY_MODEL_ID_SEQ", ingo@2825: allocationSize = 1) ingo@2825: @GeneratedValue( ingo@2825: strategy = GenerationType.SEQUENCE, ingo@2825: generator = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ") ingo@2825: @Column(name = "id") ingo@2825: public Integer getId() { ingo@2825: return id; ingo@2825: } ingo@2825: ingo@2825: public void setId(Integer id) { ingo@2825: this.id = id; ingo@2825: } ingo@2825: ingo@2825: @OneToOne ingo@2825: @JoinColumn(name = "discharge_zone_id") ingo@2825: public DischargeZone getDischargeZone() { ingo@2825: return dischargeZone; ingo@2825: } ingo@2825: ingo@2825: public void setDischargeZone(DischargeZone dischargeZone) { ingo@2825: this.dischargeZone = dischargeZone; ingo@2825: } ingo@2825: ingo@2825: @Column(name = "description") ingo@2825: public String getDescription() { ingo@2825: return description; ingo@2825: } ingo@2825: ingo@2825: public void setDescription(String description) { ingo@2825: this.description = description; ingo@2825: } ingo@2871: ingo@2871: teichmann@5323: public static List getModels(DischargeZone zone) { teichmann@5323: ingo@2871: Session session = SessionHolder.HOLDER.get(); ingo@2871: ingo@2871: Query query = session.createQuery( teichmann@5323: "from FlowVelocityModel where dischargeZone=:zone"); ingo@2871: ingo@2871: query.setParameter("zone", zone); ingo@2871: ingo@2871: return query.list(); ingo@2871: } ingo@2825: } ingo@2825: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :