이 문제를 해결하는 데 몇 시간을 보냈습니다. 아이로부터 부모를 얻으려고하면 id 필드는 모두 비어 있습니다. 그것은 단지 의미가 없습니다. 그게 프레임 워크의 끔찍한 선택 외에 아무것도 나타낼 수 있다면 PlayFramework 2.0.4를 사용하고 있습니다.JPA @ManyToOne 필드가 비어 있습니다.
TRoute.java (상위)
@Entity
@Table(name="routes")
public class TRoute extends Model {
@Id
public String route_id;
public String agency_id;
@Constraints.Required
public String route_short_name;
@Constraints.Required
public String route_long_name;
public String route_desc;
@Constraints.Required
public String route_type;
public String route_url;
public String route_color;
public String route_text_color;
@OneToMany(mappedBy="troute")
public List<Trip> trips;
public static Finder<String, TRoute> find = new Finder(
String.class, TRoute.class
);
}
Trip.java (자식)
@Entity
@Table(name="trips")
public class Trip extends Model {
@Constraints.Required
public String route_id;
@Constraints.Required
public String service_id;
@Id
public String trip_id;
public String trip_headsign;
public String direction_id;
public String block_id;
public String shape_id;
@ManyToOne
@JoinColumn(name="route_id")
public TRoute troute;
public static List<Trip> byRouteId(String route_id) {
List<Trip> trips =
Trip.find
.where().like("route_id", route_id)
.findList();
return trips;
}
public static Finder<String, Trip> find = new Finder(
String.class, Trip.class
);
}
로그가 나타내는 것은 무엇입니까? 부모에 대한 SQL 가져 오기가 표시됩니까? –
나는 Java에 익숙하지 않다. Play 프레임 워크에서 실행 한 SQL 쿼리를 볼 수있는 방법이 있습니까? – heroix