开发者

One to many relationship in app engine

开发者 https://www.devze.com 2023-03-06 05:33 出处:网络
I had two entities One is DataBase and the Other id Digraph here is the code package com.g开发者_如何学JAVAoogle.GPtest.server;

I had two entities One is DataBase and the Other id Digraph here is the code

package com.g开发者_如何学JAVAoogle.GPtest.server;

@PersistenceCapable(identityType = IdentityType.APPLICATION) public class DataBase implements 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) public class Digraph implements 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;
}

It is clear that the Digraph entity is the child of DataBase ...actually i want to make a join in that relation, does any one has an idea?

0

精彩评论

暂无评论...
验证码 换一张
取 消