Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit b54a554

Browse files
committed
jdbc: decouple hibernate modules fix jooby-project#871
1 parent b361131 commit b54a554

File tree

7 files changed

+335
-371
lines changed

7 files changed

+335
-371
lines changed

doc/doc/hbm/hbm.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This module setup and configure <a href="http://hibernate.org/orm">Hibernate ORM</a> and ```JPA Provider```.
66

7-
This module depends on [jdbc](/doc/jdbc) module, make sure you read the doc of the [jdbc](/doc/jdbc) module.
7+
> This module depends on [jdbc](/doc/jdbc) module.
88
99
## exports
1010

@@ -26,9 +26,9 @@ This module depends on [jdbc](/doc/jdbc) module, make sure you read the doc of t
2626

2727
```java
2828
{
29-
use(new Hbm("jdbc:mysql://localhost/mydb")
30-
.classes(Beer.class)
31-
);
29+
use(new Jdbc());
30+
use(new Hbm()
31+
.classes(Beer.class));
3232

3333
get("/api/beer/", req -> {
3434
return require(UnitOfWork.class).apply(em -> {
@@ -84,6 +84,7 @@ Here is an example on how to setup the open session in view filter:
8484

8585
```java
8686
{
87+
use(new Jdbc());
8788
use(new Hbm());
8889
use("*", Hbm.openSessionInView());
8990
}
@@ -130,6 +131,7 @@ Persistent classes must be provided at application startup time via [classes(Cla
130131

131132
```java
132133
{
134+
use(new Jdbc());
133135
use(new Hbm()
134136
.classes(Entity1.class, Entity2.class, ..., )
135137
);
@@ -141,6 +143,7 @@ Or via `scan`:
141143

142144
```java
143145
{
146+
use(new Jdbc());
144147
use(new Hbm()
145148
.scan()
146149
);
@@ -153,6 +156,7 @@ Which ```scan``` the application package, or you can provide where to look:
153156

154157
```java
155158
{
159+
use(new Jdbc());
156160
use(new Hbm()
157161
.scan("foo.bar", "x.y.z")
158162
);
@@ -162,15 +166,15 @@ Which ```scan``` the application package, or you can provide where to look:
162166

163167
## advanced configuration
164168

165-
Advanced configuration is provided via [doWith(Consumer)]({{defdocs}}/hbm/Hbm.html#doWith-java.util.function.Consumer-) callbacks:
169+
Advanced configuration is provided via `doWithXXX` callbacks:
166170

167171
```java
168172
{
169173
use(new Hbm()
170-
.doWith((BootstrapServiceRegistryBuilder bsrb) -> {
174+
.doWithBootstrap(bsrb -> {
171175
// do with bsrb
172176
})
173-
.doWith((StandardServiceRegistryBuilder ssrb) -> {
177+
.doWithRegistry(ssrb -> {
174178
// do with ssrb
175179
})
176180
);

doc/doc/hbm4/hbm4.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Object-Relational-Mapping via [Hibernate](http://hibernate.org/). exports an ```EntityManagerFactory``` and ```EntityManager``` services.
44

5-
This module extends [jdbc](/doc/jdbc) module, before going forward, make sure you read the doc of the [jdbc](/doc/jdbc) module first.
5+
> This module depends on [jdbc module](/doc/jdbc).
66
77
This module provides an advanced and recommended [Open Session in View](https://developer.jboss.org/wiki/OpenSessionInView#jive_content_id_Can_I_use_two_transactions_in_one_Session)
88
pattern, which basically keeps the ```Session``` opened until the view is rendered. But it uses two database transactions:
@@ -32,6 +32,8 @@ pattern, which basically keeps the ```Session``` opened until the view is render
3232

3333
```java
3434
{
35+
use(new Jdbc());
36+
3537
use(new Hbm(EntityA.class, EntityB.class));
3638

3739
get("/", req -> {
@@ -92,6 +94,7 @@ If you don't care about bootstrap time and/or just like the auto-discover featur
9294

9395
```java
9496
{
97+
use(new Jdbc());
9598
use(new Hbm().scan());
9699
}
97100
```

0 commit comments

Comments
 (0)