나는 내 모든 프로젝트를 삭제, 생성 및 나열하는 몇 가지 방법이있는 "Journey"모델 클래스가 있습니다. 나는 heroku와 postgresql 데이터베이스를 사용하고 있습니다. 지정된 주소와 비슷한 주소를 가진 모든 여행을 반환하는 메서드를 작성해야합니다. 쿼리 구조는 일반적으로 SELECT address FROM Journey WHERE address ~~ arguement
과 같을 것입니다. 그러나이 기능을 플레이 프레임 워크에서 수행하는 것이 어떤 기능인지는 알지 못합니다. 당신이 당신의 모델이를 추가 할 수 있습니다 기본 경우플레이 프레임 워크 데이터베이스 검색
List<Journey> allJourneys = Journey.find.all();
List<Journey> searchedJourneys = Journey.find.where().like("address", "%foo%").findList();
Journey firstJourney = Journey.find.byId(123);
:
package models;
import play.db.ebean.Model;
import javax.persistence.*;
@Entity
public class Journey extends Model {
@Id
public Integer id;
public static Finder<Integer, Journey> find
= new Model.Finder<>(Integer.class, Journey.class);
// other fields
public String address;
public String country;
}
그렇게 쉽게 레코드를 선택할 수 있습니다
*public static void search(String address){
//query
//return matching journey results
}*
ebean을 사용하고 있습니까? – biesior
예. application.conf - ebean.default = "models. *" –