org.datanucleus.jpa
Class NucleusJPAHelper

java.lang.Object
  extended by org.datanucleus.jpa.NucleusJPAHelper

public class NucleusJPAHelper
extends java.lang.Object

Helper for persistence operations with JPA1.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation utility for output messages
 
Constructor Summary
NucleusJPAHelper()
           
 
Method Summary
static javax.jdo.spi.JDOImplHelper getJDOImplHelper()
          Get the JDOImplHelper instance.
static javax.persistence.PersistenceException getJPAExceptionForJDOException(javax.jdo.JDOException jdoe)
          Convenience method to convert a JDO exception into a JPA exception.
static javax.persistence.PersistenceException getJPAExceptionForNucleusException(org.datanucleus.exceptions.NucleusException ne)
          Convenience method to convert a Nucleus exception into a JPA exception.
static java.lang.String getObjectState(java.lang.Object obj)
          Convenience method to return a string of the state of an object.
static boolean isDeleted(java.lang.Object obj)
          Convenience accessor for whether the object is deleted.
static boolean isDetached(java.lang.Object obj)
          Convenience accessor for whether the object is detached.
static boolean isPersistent(java.lang.Object obj)
          Convenience accessor for whether the object is persistent.
static boolean isTransactional(java.lang.Object obj)
          Convenience accessor for whether the object is transactional.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

NucleusJPAHelper

public NucleusJPAHelper()
Method Detail

isPersistent

public static boolean isPersistent(java.lang.Object obj)
Convenience accessor for whether the object is persistent.

Parameters:
obj - The object
Returns:
Whether it is persistent

isDeleted

public static boolean isDeleted(java.lang.Object obj)
Convenience accessor for whether the object is deleted.

Parameters:
obj - The object
Returns:
Whether it is deleted

isDetached

public static boolean isDetached(java.lang.Object obj)
Convenience accessor for whether the object is detached.

Parameters:
obj - The object
Returns:
Whether it is persistent

isTransactional

public static boolean isTransactional(java.lang.Object obj)
Convenience accessor for whether the object is transactional.

Parameters:
obj - The object
Returns:
Whether it is transactional

getObjectState

public static java.lang.String getObjectState(java.lang.Object obj)
Convenience method to return a string of the state of an object. Will return things like "detached", "persistent", etc

Parameters:
obj - The object
Returns:
The state

getJPAExceptionForJDOException

public static javax.persistence.PersistenceException getJPAExceptionForJDOException(javax.jdo.JDOException jdoe)
Convenience method to convert a JDO exception into a JPA exception. If the incoming exception has a "failed object" then create the new exception with a failed object. Otherwise if the incoming exception has nested exceptions then create this exception with those nested exceptions. Else create this exception with the incoming exception as its nested exception. TODO When our JPA impl doesnt depend on JDO remove this

Parameters:
jdoe - JDOException
Returns:
The JPAException

getJPAExceptionForNucleusException

public static javax.persistence.PersistenceException getJPAExceptionForNucleusException(org.datanucleus.exceptions.NucleusException ne)
Convenience method to convert a Nucleus exception into a JPA exception. If the incoming exception has a "failed object" then create the new exception with a failed object. Otherwise if the incoming exception has nested exceptions then create this exception with those nested exceptions. Else create this exception with the incoming exception as its nested exception.

Parameters:
ne - NucleusException
Returns:
The JPAException

getJDOImplHelper

public static javax.jdo.spi.JDOImplHelper getJDOImplHelper()
Get the JDOImplHelper instance. This must be done in a doPrivileged block.

Returns:
The JDOImplHelper.


Copyright © 2011. All Rights Reserved.