我有这个简单的 Java 实体,我需要使它成为 JSon 输出,我可以通过 e Web 服务实现它。
@Entity
@JsonRootName(value = "flights")
public class Flight implements Serializable {
@Transient
private static final long serialVersionUID = 1L;
public Flight() {
super();
}
public Flight(FlightDestination destinationFrom, FlightDestination destinationTo, Integer flightPrice, Date date,
Airplane airplaneDetail) {
super();
this.destinationFrom = destinationFrom;
this.destinationTo = destinationTo;
this.flightPrice = flightPrice;
this.date = date;
this.airplaneDetail = airplaneDetail;
}
public Flight(FlightDestination destinationFrom, FlightDestination destinationTo, Integer flightPrice, Date date) {
super();
this.destinationFrom = destinationFrom;
this.destinationTo = destinationTo;
this.flightPrice = flightPrice; …Run Code Online (Sandbox Code Playgroud) 我尝试输出我的实体飞行,它与我的其他实体飞机具有 OneToOne 关系,但我得到空结果并且 Eclipse 开始在 gson 中抛出异常。同样在我将此关系添加到 Flight 类之前,我的 JSON 输出没有问题。任何想法我必须改变以使其正常工作。
我的飞行课:
@Entity
@NamedQueries({ @NamedQuery(name = "Flight.getAll", query = "SELECT f FROM Flight f"), })
@NamedQuery(name = "Flight.getByDestination", query = "SELECT f FROM Flight f WHERE f.destinationFrom=:destinationFrom AND f.destinationTo=:destinationTo")
public class Flight implements Serializable {
@Transient
private static final long serialVersionUID = 1L;
public Flight() {
super();
}
public Flight(FlightDestination destinationFrom, FlightDestination destinationTo, Integer flightPrice, Date date,
Airplane airplaneDetail) {
super();
this.destinationFrom = destinationFrom;
this.destinationTo = destinationTo;
this.flightPrice = flightPrice; …Run Code Online (Sandbox Code Playgroud) 我有两个 javascript 文件,其中的变量具有相同的名称,我如何定义使用哪一个?