JPA 지속 단위에서 TaskName 지정
JPA(Java™ Persistence API) 지속 단위에서 TaskName을 지정합니다.
이 태스크 정보
TaskName은 지속 단위의 wsjpa.AccessIntent
특성 이름을 사용하여 persistence.xml 파일에서
정의됩니다. 특성 값은 TaskNames, 엔티티 유형 및 액세스 인텐트 정의의
목록입니다. 다음 예는 지속 단위에 있는
wsjpa.AccessIntent 특성 이름의 컨텐츠를
보여줍니다.
<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"
지속 단위에서 TaskName을 설정하기 전에
다음 사항에 유의하십시오. - 토큰 사이의 공백은 무시됩니다.
- <isolation> 및 <readLock> 컨텐츠만 대소문자를 구분하지 않습니다.
- <TaskName>은 완전한 패키지 메소드 이름(예: com.acme.bean.MyBean.increment) 또는 임의로 사용자 정의된 태스크 이름(예: MyProfile) 형식입니다.
- <entityName>은 완전한 패키지 클래스 이름(예: com.acme.bean.Entity1) 형식입니다.
- 와일드카드 문자 '?' 또는 '*'를 <TaskName> 및 <entityName>에 사용할 수 있습니다. "?" 는 모든 단일 문자와 일치하고 "*"는 0개 이상의 시퀀스 문자와 일치합니다.
- 태스크 정의에는 hintNames isolation 및 readLock만 허용되며 순서는 중요하지 않습니다.
- readLock의 값이 write이면 isolation은 repeatable-read 또는 serializable이어야 합니다.
- readLock 값이 read이면 isolation이 read-uncommitted일 때 영향을 주지 않습니다.
다음 코드 예는 JPA 지속 단위에서 TaskName을
지정하는 방법을 보여줍니다.
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
}
}
TaskName 및 엔티티 유형을 지정할 때 와일드카드를
사용할 수 있으므로 런타임 시에 다중 스펙 일치 항목이 발생할 수 있습니다.
wsjpa.AccessIntent 특성에 정의된 순서에 따라
태스크 이름 및 엔티티 유형을 검색합니다.
<properties>
<property name="wsjpa.AccessIntent" value="Tasks="
*.Task1 { *.Employee1 ( isolation=read-uncommitted ),
*.Employee? ( isolation=repeatable-read, readlock=write ),
},
* { *.Employee3 ( isolation=serializable, readlock=write ) },
'" />
</properties>