Update use example in README

This commit is contained in:
Rob Bygrave
2022-09-07 14:03:37 +12:00
parent 03bd31677a
commit dd95081e63
+18 -5
View File
@@ -9,21 +9,34 @@ to integrate with Springs JDBC Transaction manager.
## To use
```java
ServerConfig serverConfig = new ServerConfig();
DatabaseConfig config = new DatabaseConfig();
// set SpringJdbcTransactionManager ... as the external transaction manager
serverConfig.setExternalTransactionManager(new SpringJdbcTransactionManager());
config.setExternalTransactionManager(new SpringJdbcTransactionManager());
...
EbeanServer server = EbeanServerFactory.create(serverConfig);
Database database = DatabaseFactory.create(config);
```
## Notes
You can use Ebean in Spring/Spring Boot *without* this and that case Ebean
manages the Transactions itself. With Ebean managing the transactions there
manages the Transactions itself. With Ebean managing the transactions there
are some benefits with more control over JDBC batch, getGeneratedKeys
and a simpler abstraction (as Spring transactions is designed to manage
multiple resources such as JDBC Transactions and JPA EntityManager and Ebean
only needs to manage JDBC Transactions).
only needs to manage JDBC Transactions).
## Java modules
The module name is `io.ebean.spring.txn`
```java
module foo {
requires io.ebean.spring.txn;
...
}
```