应用引擎中的一对多关系

时间:2011-05-13 16:08:59

标签: google-app-engine jdo

我有两个实体,一个是DataBase,另一个ID是Digraph,这里是代码

package com.google.GPtest.server;

@PersistenceCapable(identityType = IdentityType.APPLICATION) 公共类DataBase实现Serializable {

  /**
 * 
 */
private static final long serialVersionUID = 1L;
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long pid;
 // @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
  @Persistent
  private String id;
  @Persistent
  private User user;
  @Persistent
  private double press='\0';
  @Persistent
  private double release='\0';
  /*@Persistent
  private double time='\0';*/
  @Persistent
  private int index;
  @Persistent
  private String value;
  @Persistent
  private String  location;
  @Persistent
  private Date createDate;
  @Persistent(mappedBy="data")
  private List<Digraph> sig=new ArrayList<Digraph>();

  public DataBase(String id,User user, String value,double press,double release,int index,String location) {

        this.user = user;
        this.setValue(value);
        this.setPress(press);
        this.setRelease(release);
        this.setIndex(index);
        this.setLocation(location);
        this.setId(id);
    this.createDate = new Date();
  }



  public String getId() {
    return this.id;
  }
  public void setId(String id){
      this.id=id;
  }

  public User getUser() {
    return this.user;
  }

  /*public String getSymbol() {
    return this.symbol;
  }*/

  public Date getCreateDate()           {
    return this.createDate;
  }

  public void setUser(User user) {
    this.user = user;
  }

public void setValue(String value) {
    this.value = value;
}

public String getValue() {
    return value;
}

public void setIndex(int index) {
    this.index = index;
}

public int getIndex() {
    return index;
}

/*public void setTime(double time) {
    this.time = time;
}

public double getTime() {
    return time;
}*/

public void setRelease(double release) {
    this.release = release;
}

public double getRelease() {
    return release;
}

public void setPress(double press) {
    this.press = press;
}

public double getPress() {
    return press;
}



public void setLocation(String location) {
    this.location = location;
}



public String getLocation() {
    return location;
}



public void setSig(List<Digraph> sig) {
    this.sig = sig;
}



public List<Digraph> getSig() {
    return sig;
}

  /*public void setSymbol(String symbol) {
    this.symbol = symbol;
  }*/

}

@PersistenceCapable(identityType = IdentityType.APPLICATION) 公共类Digraph实现Serializable {

/**
 * 
 */
private static final long serialVersionUID = 1L;

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

@Persistent
private String name;

@Persistent
private DataBase data;

public Digraph(String name){
    this.name=name;
}

public void setName(String name) {
    this.name = name;
}

public String getName() {
    return name;
}

public void setData(DataBase data) {
    this.data = data;
}

public DataBase getData() {
    return data;
}

很明显,Digraph实体是DataBase的孩子......实际上我想在那个关系中建立一个连接,是否有人有想法?

0 个答案:

没有答案