Skip to content

Commit 44cd9a9

Browse files
Docs for transactions
1 parent 4ee78f0 commit 44cd9a9

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
* xref:configuration.adoc[Configuration]
44
* xref:working-copies.adoc[Working Copies]
55
* xref:lazies.adoc[Lazy References]
6+
* xref:transactions.adoc[Transactions]
67
* xref:migration.adoc[Migration]
78
* xref:known-issues.adoc[Known issues]

docs/modules/ROOT/pages/lazies.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Owner extends Person
3131
//...
3232
----
3333

34-
== Internas
34+
== Internals
3535

3636
SpringDataEclipseStoreLazies work as a proxy for the EclipseStore-Lazies.
3737
As far as EclipseStore is concerned, a SpringDataEclipseStoreLazy-Object is a normal Java object that contains a Lazy-Reference.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
= Transactions
2+
3+
[quote,https://docs.spring.io/spring-framework/reference/data-access/transaction.html[spring - Transaction Management]]
4+
5+
____
6+
Comprehensive transaction support is among the *most compelling reasons* to use the Spring Framework.
7+
____
8+
9+
That's why we implemented *Spring Transactions*.
10+
11+
Just like Spring JPA you can use https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative.html[declarative] or https://docs.spring.io/spring-framework/reference/data-access/transaction/programmatic.html[programmatic] transaction management.
12+
13+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/VetService.java[Declarative example from complex demo]"]
14+
----
15+
import org.springframework.stereotype.Service;
16+
import org.springframework.transaction.annotation.Transactional;
17+
//...
18+
@Service
19+
@Transactional
20+
public class VetService
21+
{
22+
//...
23+
public void saveNewEntries()
24+
{
25+
final Vet vet = this.createVet();
26+
this.vetRepository.save(vet);
27+
}
28+
//...
29+
----
30+
31+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/OwnerService.java[Programmatic example from complex demo]"]
32+
----
33+
import org.springframework.stereotype.Service;
34+
import org.springframework.transaction.PlatformTransactionManager;
35+
//...
36+
@Service
37+
public class OwnerService
38+
{
39+
private final PlatformTransactionManager transactionManager;
40+
41+
@Autowired
42+
public OwnerService(
43+
final OwnerRepository ownerRepository,
44+
final PlatformTransactionManager transactionManager)
45+
{
46+
this.ownerRepository = ownerRepository;
47+
this.transactionManager = transactionManager;
48+
}
49+
//...
50+
public void deleteAll()
51+
{
52+
new TransactionTemplate(this.transactionManager).execute(
53+
status ->
54+
{
55+
this.ownerRepository.deleteAll();
56+
return null;
57+
});
58+
}
59+
//...
60+
----
61+
62+
CAUTION: If you are using transaction, you need to define a ``Bean`` for ``PlatformTransactionManager``! This is easiest achieved by extending the ``EclipseStoreClientConfiguration``. See https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/ComplexConfiguration.java[the complex demo].

0 commit comments

Comments
 (0)