|
For those who want to know….
Code in application:
Product dbProduct = null; try { Object object = pm.getObjectId(product); dbProduct = (Product) pm.getObjectById(new Product.ID(product.getPOSFILE_DET_GTIN())); } catch (Throwable t) { t.printStackTrace(); }
Must add inner class in jdo object public static class ID implements java.io.Serializable { public String POSFILE_DET_GTIN;
public ID() {
}
public ID(String s) { POSFILE_DET_GTIN = s; }
public boolean equals(Object o) { if (this == o) { return true; }
if (!(o instanceof Product.ID)) { return false; }
final Product.ID id = (Product.ID) o; if (this.POSFILE_DET_GTIN != id.POSFILE_DET_GTIN) { return false; }
if (this.POSFILE_DET_GTIN != id.POSFILE_DET_GTIN) { return false; } return true; }
Then specify inner class inside jdo metadata file: <class name="Product" table="Product" requires-extent="true" identity-type="application" objectid-class="Product$ID">
And it works!!!
-----Original Message-----
I am trying to determine if I must do an insert or update by trying to get the object from the db by using the primary key.
Something like this:
Product dbProduct = (Product)pm.getObjectById(primaryKey); If (dbProduct != null) { //update } else { //insert }
I keep getting: javax.jdo.JDOObjectNotFoundException: No such object FailedObject:2050000001574
The object is there but its throwing its toys? Leon van der Merwe Programmer Bytes Specialised Solutions
A division of Bytes Technology Group SA (Pty) Ltd :
Registration No: 2003/027603/07 E-Mail Disclaimer: http://www.altron.co.za/email.asp or phone: (+27) (11) 645-3600
|
- [CTJUG Forum] Re: JDO - getObjectById() Bertram Julius
- [CTJUG Forum] Re: JDO - getObjectById() Leon van der Merwe
