public class

JPAModule

extends Object
implements MuleContextAware
java.lang.Object
   ↳ org.mule.module.jpa.JPAModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Java Persistence API (JPA) support for Mule.

Summary

Fields
EntityManagerFactory entityManagerFactory Reference to an EntityManagerFactory
protected Log logger
MuleContext muleContext
Public Constructors
JPAModule()
Public Methods
void connect()
Object detach(Object entity, Boolean flush)
Detaches the message's payload from the session.
Object find(String entityClass, Object id, Boolean flush)
Looks up an entity using the message's payload as the primary key.
EntityManagerFactory getEntityManagerFactory()
Object merge(Object entity, Boolean flush)
Merges the payload of the message.
Object persist(Object entity, Boolean flush)
Persists the payload of the message.
Object query(CriteriaQuery criteria, String statement, String namedQuery, Object queryParameters, Boolean flush)
Execute a JPA query.
void setEntityManagerFactory(EntityManagerFactory entityManagerFactory)
void setMuleContext(MuleContext muleContext)
Object upsert(Object entity, Object id, String fields, boolean flush)
Upserts an entity

[Expand]
Inherited Methods
From class java.lang.Object
From interface org.mule.api.context.MuleContextAware

Fields

EntityManagerFactory entityManagerFactory

Reference to an EntityManagerFactory

protected Log logger

MuleContext muleContext

Public Constructors

public JPAModule ()

Public Methods

public void connect ()

Throws
Exception

public Object detach (Object entity, Boolean flush)

Detaches the message's payload from the session.

Parameters
entity The entity to detach.
flush Flush the session if true
Returns
  • the inserted object
Throws
Exception An exception when there's an error

public Object find (String entityClass, Object id, Boolean flush)

Looks up an entity using the message's payload as the primary key.

Parameters
entityClass The class of the entity to find.
id The ID of the entity to find.
flush Flush the session if true
Returns
  • The entity or null if it isn't found.
Throws
Exception An exception when there's an error

public EntityManagerFactory getEntityManagerFactory ()

public Object merge (Object entity, Boolean flush)

Merges the payload of the message.

Parameters
entity The entity to persist.
flush Flush the session if true
Returns
  • the merged object
Throws
Exception An exception when there's an error

public Object persist (Object entity, Boolean flush)

Persists the payload of the message.

Parameters
entity The entity to persist.
flush Flush the session if true
Returns
  • the persisted object
Throws
Exception An exception when there's an error

public Object query (CriteriaQuery criteria, String statement, String namedQuery, Object queryParameters, Boolean flush)

Execute a JPA query. If the payload of the message is a List or Map then its used as the query parameters. If neither statement nor namedQuery are set then the payload of the message is assumed to be a CriteriaQuery instance.

Parameters
criteria The CriteriaQuery
statement A JPA QL statement to execute
namedQuery A named query to execute
queryParameters The query parameters
flush Flush the session if true
Returns
  • The query results
Throws
Exception An exception when there's an error

public void setEntityManagerFactory (EntityManagerFactory entityManagerFactory)

Parameters
entityManagerFactory

public void setMuleContext (MuleContext muleContext)

Parameters
muleContext

public Object upsert (Object entity, Object id, String fields, boolean flush)

Upserts an entity

Parameters
entity The entity to upsert.
id The id of the object to lookup
fields The fields to update
flush Flush the sesssion if true
Returns
  • the upserted entity
Throws
Exception An exception when there's an error.