Thanks Stephan Hartmann,
But there is another problem now .
Does the DataStore will have a Foreign Key of Department in Employee?
And , is it visible in the Employee table?
Following are my POJO's ::::::
/////////////////////////////////////Department///////////////////////////////////////////
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import com.google.appengine.api.datastore.Key;
/**
* @author Sushama Khadilkar.
*
* Create Date : 17-Feb-2010
*/
@SuppressWarnings("serial")
@Entity
public class Department implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Key dept_id;
private String dept_name;
private String head;
@OneToMany(mappedBy="department")
public List<Employee>employee;
public Key getDept_id() {
return dept_id;
}
public void setDept_id(Key dept_id) {
this.dept_id = dept_id;
}
public String getDept_name() {
return dept_name;
}
public void setDept_name(String dept_name) {
this.dept_name = dept_name;
}
public String getHead() {
return head;
}
public void setHead(String head) {
this.head = head;
}
public List<Employee> getEmployee() {
return employee;
}
public void setEmployee(List<Employee> employee) {
this.employee = employee;
}
}
//////////////////////////////////////////////////////////////Employee/////////////////////////////////////////////////////////
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import com.google.appengine.api.datastore.Key;
/**
* @author Sushama Khadilkar.
*
* Create Date : 17-Feb-2010
*/
@SuppressWarnings("serial")
@Entity
public class Employee implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Key emp_id;
private String emp_name;
private String emp_sal;
@ManyToOne(cascade = CascadeType.ALL)
private Department department;
public Key getEmp_id() {
return emp_id;
}
public void setEmp_id(Key emp_id) {
this.emp_id = emp_id;
}
public String getEmp_name() {
return emp_name;
}
public void setEmp_name(String emp_name) {
this.emp_name = emp_name;
}
public String getEmp_sal() {
return emp_sal;
}
public void setEmp_sal(String emp_sal) {
this.emp_sal = emp_sal;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.