0
我有1類ContainerLoadList與複合鍵ContainerLoadListPK這樣如何創建方法從CrudRepository延長複合鍵
@Embeddable
public class ContainerLoadListPK implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3526479259987259367L;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 13)
@Column(name = "ContainerNo")
private String containerNo;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 6)
@Column(name = "VesselCode")
private String vesselCode;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 8)
@Column(name = "Voyage")
private String voyage;
public ContainerLoadListPK() {
}
public ContainerLoadListPK(String containerNo, String vesselCode, String voyage) {
this.containerNo = containerNo;
this.vesselCode = vesselCode;
this.voyage = voyage;
}
public String getContainerNo() {
return containerNo;
}
public void setContainerNo(String containerNo) {
this.containerNo = containerNo;
}
public String getVesselCode() {
return vesselCode;
}
public void setVesselCode(String vesselCode) {
this.vesselCode = vesselCode;
}
public String getVoyage() {
return voyage;
}
public void setVoyage(String voyage) {
this.voyage = voyage;
}
}
和我有另一個接口從CrudRepository擴展這樣
public interface ContainerLoadListRepository extends CrudRepository<ContainerLoadList, ContainerLoadListPK> {
List<ContainerLoadList> findByBNo(@Param("bNo") String bNo);
@Query(name = "ContainerLoadList.findByVesselCodeAndVoyage")
List<ContainerLoadList> findByVesselCodeAndVoyage(@Param("vesselCode") String vesselCode,@Param("voyage") String voyage);
}
是你沒有使用@Query,爲findByVesselCodeAndVoyage提供另一個解決方案?