[ Team LiB ] |
11.2 State InterrogationThe JDOHelper class provides the following methods to interrogate the state of an instance: static boolean isPersistent(Object obj); static boolean isTransactional(Object obj); static boolean isDirty(Object obj); static boolean isNew(Object obj); static boolean isDeleted(Object obj); Each of these methods returns false if the instance is null, transient, or of a class that is not persistent. Otherwise, these methods return the following:
Table 11-1 specifies the values these methods return for each required lifecycle state. You could write a method that calls each of these methods and returns a String denoting the instance's lifecycle state. This can be useful if you are debugging or would like to know the lifecycle state of instances.
Table A-1 in Appendix A provides a complete listing of the values these methods return for all the lifecycle states. |
[ Team LiB ] |