และต้องเป็นโรงพยาบาลที่อยู่ในโครงการ (InHospital) เท่านั้น
package com.blogspot.na5cent.api.repository; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import com.blogspot.na5cent.basicmodel.readonly.Hospital; import com.blogspot.na5cent.basicmodel.readonly.Province; /** * * @author redcrow */ public interface HospitalRepository extends JpaRepository<Hospital, String>{ @Query("SELECT hp FROM InHospital inHp INNER JOIN inHp.hospital hp WHERE hp.province = ?1") public List<Hospital> findByProvince(Province province); }Hospital.java
... ... ... @Entity @Table(name = "hospital") @ReadOnly public class Hospital implements Serializable { @Id @Column(nullable = false, length = 5) private String hcode; @Column(nullable = false, length = 250) private String hname; @ManyToOne @JoinColumn(name = "province_id", nullable = false) private Province province; ... ... ... }InHospital.java
... ... ... @Entity @Table(name = "in_hospital") public class InHospital implements Serializable { @Id @Column(name = "hcode", length = 9) private String hcode; @Version private Integer version; @OneToOne @JoinColumn(name = "hcode", insertable = false, updatable = false) private Hospital hospital; .... .... .... }
ไม่มีความคิดเห็น:
แสดงความคิดเห็น