Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop EJB applications > Assembling applications that use the Java Persistence API > Use JPA access intent
Specify TaskName in a JPA persistence unit
Specifying a TaskName in Java Persistence API (JPA) persistence unit
A TaskName is defined in the persistence.xml file using the wsjpa.AccessIntent property name in a persistence unit. The property value is a list of TaskNames, entity types and access intent definitions. The following example shows the contents of the wsjpa.AccessIntent property name in a persistence unit.
<property name = "wsjpa.AccessIntent" value = "Tasks=' <taskName> { <entityName> ( <isolationLockValue> ) } ' "/> A A A | | | | | +--------- , --------+ | | | +----------------- , -----------------+ | +----------------------- , --------------------------+ Tasks ::= <task> [ ',' <task> ]* <task> ::= <taskName> '{' <entity> [ ',' <entity> ]* '}' <entity> ::= <entityName> '(' <isolationLockValues> ')' <taskName> ::= <fully_qualified_identifier> <entityName> ::= <fully_qualified_identifier> <fully_qualified_identifier> ::= <identifier> [ '.' <identifier> ]* <identifier> ::= <idStartCharacter> [ <idCharacter> ]* <idStartCharacter> ::= Character.isJavaIdentifierStart | '?' | '*' <idStartCharacter> ::= Character.isJavaIdentifierPart | '?' | '*' <isolationLockValues> ::= <isolationLockValue> [ ',' <isolationLockValue> ] <isolationLockValue> ::= <isolation> | <readLock> <isolation> ::= "isolation" '=' <isolationValue> <readLock> ::= "readlock" '=' <readlockValue> <isolationValue> ::= "read-uncommitted"|"read-committed"|"repeatable-read"|"serializable" <readlockValue> ::= "read" | "write"Before setting the TaskName in a persistence unit, keep the following in mind:
- White spaces are ignored between tokens.
- Only <isolation> and <readLock> contents are not case sensitive.
- <TaskName> is in the form of a fully package qualified method name, such as com.acme.bean.MyBean.increment, or an arbitrary user-defined task name, such as MyProfile.
- <entityName> is in the form of a fully package qualified class name such as com.acme.bean.Entity1.
- The wild card characters '?' or '*' can be used in <TaskName> and <entityName>. "?" matches any single character and "*" matches zero or more sequence characters.
- Only hintNames isolation and readLock are allowed on a task definition and the order is not significant
- If readLock has the value write, then isolation must be repeatable-read or serializable
- If readLock has the value read, it has no effect if the isolation is read-uncommitted.
The following code example shows how to specify a TaskName in JPA persistence unit.
package my.company; @Remote class Ejb1 { // assumer no tx from the caller @TransactionAttribute(Requires) public void caller_Method1() { // an implicit new transaction begins // TaskName "my.company.Ejb1.caller_Method1" set on TSR ejb1.callee_Method?(); } @TransactionAttribute(RequiredNew) public void callee_Method2() { // an implicit new transaction begins i.e. TxRequiredNew. // TaskName "my.company.Ejb1.callee_Method2" set on TSR } @TransactionAttribute(Requires) public void callee_Method3() { // In caller's transaction, hence TaskName remains // "my.company.Ejb1.caller_Method1" } @TransactionAttribute(NotSupported) public void callee_LocalTx () { // Unspecified transaction, a new local transaction implicitly started. // TaskName "my.company.Ejb1.callee_LocalTx" set on TSR } }Since a wild card can be used to specify TaskName and entity type, multiple specification matches may occur at runtime. The order defined in the wsjpa.AccessIntent property will be used to search for task names and entity types.
<properties> <property name="wsjpa.AccessIntent" value="Tasks=" *.Task1 { *.Employee1 ( isolation=read-uncommitted ), *.Employee? ( isolation=repeatable-read, readlock=write ), }, * { *.Employee3 ( isolation=serializable, readlock=write ) }, '" /> </properties>
Use JPA access intent
Set a TaskName using TaskNameAccessor API