Re: [appengine-java] Null Pointer Exception at the time of transaction commit.
Thanks, But i'm not getting wat are u saying so can u plz explain clearly... -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] Re: Editing records in datastore (using JAVA)
If you want to update the record using EntityManager , then just use em.merge(Object). This the link to the Example:: http://www.javabeat.net/articles/81-jpa-in-netbeans-61-4.html -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: NullPointerException at Transaction.commit()
Max, Actually that problem is solved .I completely changed my POJO's and that error is gone . But now i have one more question to you Question How can i send a list of employees in a particular department , because i tried it using Set & List but it is giving me a error . So could you plz tell me how to do that. I have a list of employees in Deparment POJO. -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] Null Pointer Exception at the time of transaction commit.
Thanks Again Stephan Hartmann,But can u tell me one thing , >> > cant we use List or Set or something else for the return type of the addEmp() method. because while using Set as a return type in Async & in greeting Service i m gettin a error. so plz can u tell it me. Plz Plz. The output is:: Compiling module com.employeedepartmentgae.Employeedepartmentgae Refreshing module from source Validating newly compiled units Removing units with errors [ERROR] Errors in 'file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/GreetingServiceAsync.java' [ERROR] Line 6: The import com.employeedepartmentgae.server.domainobject.Employee cannot be resolved [ERROR] Line 18: Employee cannot be resolved to a type [ERROR] Errors in 'file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/GreetingService.java' [ERROR] Line 6: The import com.employeedepartmentgae.server.domainobject.Employee cannot be resolved [ERROR] Line 20: Employee cannot be resolved to a type [ERROR] Errors in 'file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/EmployeeWidget.java' [ERROR] Line 12: The import com.employeedepartmentgae.server.domainobject.Employee cannot be resolved [ERROR] Line 75: The method addEmp(String, String, String, AsyncCallback>) from the type GreetingServiceAsync refers to the missing type Employee [ERROR] Line 75: The type new AsyncCallback>(){} must implement the inherited abstract method AsyncCallback>.onSuccess(Set) [ERROR] Line 75: Employee cannot be resolved to a type [ERROR] Line 94: The method onSuccess(Set) of type new AsyncCallback>(){} must override or implement a supertype method [ERROR] Line 94: Employee cannot be resolved to a type [ERROR] Line 96: Employee cannot be resolved to a type [ERROR] Line 96: Employee cannot be resolved to a type [ERROR] Line 98: Employee cannot be resolved to a type Removing invalidated units [WARN] Compilation unit 'file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/Employeedepartmentgae.java' is removed due to invalid reference(s): [WARN] file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/EmployeeWidget.java [WARN] Compilation unit 'file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/DepartmentWidget.java' is removed due to invalid reference(s): [WARN] file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/GreetingService.java [WARN] file:/home/wissen18/employeedepartmentgae/src/com/employeedepartmentgae/client/GreetingServiceAsync.java Computing all possible rebind results for 'com.employeedepartmentgae.client.Employeedepartmentgae' Rebinding com.employeedepartmentgae.client.Employeedepartmentgae Checking rule [ERROR] Unable to find type 'com.employeedepartmentgae.client.Employeedepartmentgae' [ERROR] Hint: Previous compiler errors may have made this type unavailable [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] Null Pointer Exception at the time of transaction commit.
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 Listemployee; 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 getEmployee() { return employee; } public void setEmployee(List 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Null Pointer Exception at the time of transaction commit.
package com.wissen.enterprisebysush.server; import java.util.List; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.Query; import com.google.gwt.user.client.Window; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.wissen.enterprisebysush.client.GreetingService; import com.wissen.enterprisebysush.server.domainobject.Department; import com.wissen.enterprisebysush.server.domainobject.Employee; /** * The server side implementation of the RPC service. */ @SuppressWarnings("serial") public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService { EntityManagerFactory emf = Persistence.createEntityManagerFactory("transactions-optional"); public String greetServer(String input) { String serverInfo = getServletContext().getServerInfo(); String userAgent = getThreadLocalRequest().getHeader("User-Agent"); return "Hello, " + input + "!I am running " + serverInfo + ".It looks like you are using:" + userAgent; } @SuppressWarnings("unchecked") public void addDept(String dept_name, String dept_head) { EntityManager em = null; try { em = emf.createEntityManager(); em.getTransaction().begin(); Department d = new Department(); d.setDept_name(dept_name); d.setHead(dept_head); Query q = em.createQuery("select from com.wissen.enterprisebysush.server.domainobject.Department d"); List deptList = q.getResultList(); for (Department dept : deptList) { System.out.println("Department name: " + dept.getDept_name()); } em.persist(d); } finally { em.getTransaction().commit(); em.close(); } } public void addEmp(String emp_name, String emp_sal, String did) { EntityManager em = emf.createEntityManager(); try { String s = did; EntityTransaction transaction = em.getTransaction(); transaction.begin(); System.out.println("value of Department_name is::" + s); System.out.println("Transaction is active and is::"+transaction); //Query q = em.createQuery("select dept_id from com.wissen.enterprisebysush.server.domainobject.Department d where d.dept_name = ?1"); //q.setParameter(1, s); //System.out.println("Name of Department is::" + s); //Department dept = (Department) q.getSingleResult(); Query q = em.createQuery("select from com.wissen.enterprisebysush.server.domainobject.Department d"); Department dept = (Department) q.getResultList().get(0); System.out.println("Name of Department is::" + dept.getDept_name()); //System.out.println("Query executed Successfully!!" + q.getSingleResult()); Employee e = new Employee(); e.setEmp_name("Abcdh"); e.setEmp_sal("5000"); e.setDepartment(dept); em.persist(e); System.out.println("Transaction: " + transaction); transaction.commit(); em.close(); } catch (NullPointerException e) { e.printStackTrace(); System.out.println("Exception::" + e.getCause()); } finally { } } } Output is:: The server is running at http://localhost:8090/ value of Department_name is::Production Transaction is active and is::org.datanucleus.jpa.entitytransactioni...@1a21c7d Name of Department is::Accounts Transaction: org.datanucleus.jpa.entitytransactioni...@1a21c7d java.lang.NullPointerException Exception::nullat com.google.appengine.api.datastore.KeyFactory.stringToKey(KeyFactory.java:181) at org.datanucleus.store.appengine.DatastoreElementContainerStoreSpecialization.extractElementKey(DatastoreElementContainerStoreSpecialization.java:170) at org.datanucleus.store.appengine.DatastoreAbstractCollectionStoreSpecialization.contains(DatastoreAbstractCollectionStoreSpecialization.java:57) at org.datanucleus.store.mapped.scostore.AbstractCollectionStore.contains(AbstractCollectionStore.java:116) at org.datanucleus.sco.backed.List.contains(List.java:455) at org.datanucleus.state.RelationshipManager.processManyToOneBidirectionalRelation(RelationshipManager.java:690) at org.datanucleus.state.RelationshipManager.process(RelationshipManager.java:294) at org.datanucleus.state.JDOStateManagerImpl.processManagedRelations(JDOStateManagerImpl.java:2377) at org.datanucleus.ObjectManagerImpl.performManagedRelationships(ObjectManagerImpl.java:2706) a