org.mule.modules

mule-module-jpa

config

Namespacehttp://www.mulesoft.org/schema/mule/jpa
Schema Locationhttp://www.mulesoft.org/schema/mule/jpa/current/mule-jpa.xsd  (View Schema)
Schema Version1.0
Minimum Mule Version3.2

Module Overview

Java Persistence API (JPA) support for Mule.

Summary

Configuration
<jpa:config>
Configure an instance of this module
Message Processors
<jpa:detach>
Detaches the message's payload from the session.
<jpa:find>
Looks up an entity using the message's payload as the primary key.
<jpa:merge>
Merges the payload of the message.
<jpa:persist>
Persists the payload of the message.
<jpa:query>
Execute a JPA query.
<jpa:upsert>
Upserts an entity

Configuration

To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jpa="http://www.mulesoft.org/schema/mule/jpa"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/jpa
               http://www.mulesoft.org/schema/mule/jpa/current/mule-jpa.xsd">

      <!-- here goes your flows and configuration elements -->

</mule>

This module is configured using the config element. This element must be placed outside of your flows and at the root of your Mule application. You can create as many configurations as you deem necessary as long as each carries its own name.

Each message processor, message source or transformer carries a config-ref attribute that allows the invoker to specify which configuration to use.

Attributes
TypeNameDefault ValueDescriptionJava TypeMIME TypeEncoding
xs:string name Optional. Give a name to this configuration so it can be later referenced.
entityManagerFactory Reference to an EntityManagerFactory

Message Processors

<jpa:detach>

Detaches the message's payload from the session.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
entity The entity to detach. Object */*
flush false Optional. Flush the session if true Boolean */*
Returns
Return Type Description
Object the inserted object
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error

<jpa:find>

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

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
entityClass The class of the entity to find. String */* UTF-8
id The ID of the entity to find. Object */*
flush false Optional. Flush the session if true Boolean */*
Returns
Return Type Description
Object The entity or null if it isn't found.
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error

<jpa:merge>

Merges the payload of the message.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
entity The entity to persist. Object */*
flush false Optional. Flush the session if true Boolean */*
Returns
Return Type Description
Object the merged object
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error

<jpa:persist>

Persists the payload of the message.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
entity The entity to persist. Object */*
flush false Optional. Flush the session if true Boolean */*
Returns
Return Type Description
Object the persisted object
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error

<jpa:query>

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.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
criteria Optional. The CriteriaQuery CriteriaQuery */*
statement Optional. A JPA QL statement to execute String */* UTF-8
namedQuery Optional. A named query to execute String */* UTF-8
queryParameters Optional. The query parameters Object */*
flush false Optional. Flush the session if true Boolean */*
Returns
Return Type Description
Object The query results
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error

<jpa:upsert>

Upserts an entity

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
entity The entity to upsert. Object */*
id The id of the object to lookup Object */*
fields The fields to update String */* UTF-8
flush false Optional. Flush the sesssion if true boolean */*
Returns
Return Type Description
Object the upserted entity
Exception Payloads
Payload ClassDescription
Exception An exception when there's an error.

Message Sources

Transformers