4.1. Determining the state of an instance

The PersistenceManager internally knows the state of a JDO instance. Although it is not possible for us to determine the state of an instance precisely (some states being invisible to the application), we can get an excellent representation of an instance’s state by using the JDOHelper class.

Five methods of JDOHelper give us information from which an approximation of an instance’s state can be achieved. These are:

  • public static boolean isDeleted(Object pc)

    Returns true if the object has been deleted in the current transaction.

  • public static boolean isDirty(Object pc)

    Returns true if the object has had a persistent field value altered in the current transaction.

  • public static boolean isNew(Object pc)

    Returns ...

Get Java™ Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.