You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/first-entity.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,13 @@ Non-nullable fields (like `city: City`) produce `INNER JOIN` queries. Nullable f
33
33
<TabItemvalue="java"label="Java">
34
34
35
35
```java
36
+
@Builder(toBuilder=true)
36
37
record City(@PKInteger id,
37
38
String name,
38
39
long population
39
40
) implements Entity<Integer> {}
40
41
42
+
@Builder(toBuilder=true)
41
43
record User(@PKInteger id,
42
44
String email,
43
45
String name,
@@ -47,6 +49,8 @@ record User(@PK Integer id,
47
49
48
50
In Java, record components are nullable by default. Use `@Nonnull` on fields that must always have a value. Primitive types (`int`, `long`, etc.) are inherently non-nullable.
49
51
52
+
The `@Builder` annotation is from [Lombok](https://projectlombok.org/) and is optional. It generates a builder that lets you construct entities without specifying the primary key, and creates modified copies via `toBuilder()`. Without Lombok, you can pass `null` as the primary key (e.g., `new City(null, "Sunnyvale", 155_000)`) or define a convenience constructor that omits it. See [Modifying Entities](entities.md#modifying-entities) for details.
53
+
50
54
</TabItem>
51
55
</Tabs>
52
56
@@ -129,10 +133,17 @@ var cities = orm.entity(City.class);
129
133
var users = orm.entity(User.class);
130
134
131
135
// Insert a city -- the returned object has the database-generated ID
132
-
City city = cities.insertAndFetch(newCity(null, "Sunnyvale", 155_000));
136
+
City city = cities.insertAndFetch(City.builder()
137
+
.name("Sunnyvale")
138
+
.population(155_000)
139
+
.build());
133
140
134
141
// Insert a user that references the city
135
-
User user = users.insertAndFetch(newUser(null, "alice@example.com", "Alice", city));
142
+
User user = users.insertAndFetch(User.builder()
143
+
.email("alice@example.com")
144
+
.name("Alice")
145
+
.city(city)
146
+
.build());
136
147
```
137
148
138
149
The `insertAndFetch` method sends an INSERT statement, retrieves the auto-generated primary key, and returns a new record with the key populated.
@@ -237,7 +248,11 @@ With Spring's `@Transactional`:
237
248
@Transactional
238
249
publicUser createUser(String email, String name, City city) {
Copy file name to clipboardExpand all lines: docs/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ import TabItem from '@theme/TabItem';
23
23
24
24
## Why Storm?
25
25
26
-
Storm draws inspiration from established ORMs such as Hibernate, but is built from scratch around a clear design philosophy: capturing exactly what you want to do using the minimum amount of code, optimized for Kotlin and modern Java
26
+
Storm draws inspiration from established ORMs such as Hibernate, but is built from scratch around a clear design philosophy: capture intent using the minimum amount of code, optimized for Kotlin and modern Java.
27
27
28
28
**Storm's mission:** Make database development productive and enjoyable, with full developer control and high performance.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-1.10.0/first-entity.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,13 @@ Non-nullable fields (like `city: City`) produce `INNER JOIN` queries. Nullable f
33
33
<TabItemvalue="java"label="Java">
34
34
35
35
```java
36
+
@Builder(toBuilder=true)
36
37
record City(@PKInteger id,
37
38
String name,
38
39
long population
39
40
) implements Entity<Integer> {}
40
41
42
+
@Builder(toBuilder=true)
41
43
record User(@PKInteger id,
42
44
String email,
43
45
String name,
@@ -47,6 +49,8 @@ record User(@PK Integer id,
47
49
48
50
In Java, record components are nullable by default. Use `@Nonnull` on fields that must always have a value. Primitive types (`int`, `long`, etc.) are inherently non-nullable.
49
51
52
+
The `@Builder` annotation is from [Lombok](https://projectlombok.org/) and is optional. It generates a builder that lets you construct entities without specifying the primary key, and creates modified copies via `toBuilder()`. Without Lombok, you can pass `null` as the primary key (e.g., `new City(null, "Sunnyvale", 155_000)`) or define a convenience constructor that omits it. See [Modifying Entities](entities.md#modifying-entities) for details.
53
+
50
54
</TabItem>
51
55
</Tabs>
52
56
@@ -129,10 +133,17 @@ var cities = orm.entity(City.class);
129
133
var users = orm.entity(User.class);
130
134
131
135
// Insert a city -- the returned object has the database-generated ID
132
-
City city = cities.insertAndFetch(newCity(null, "Sunnyvale", 155_000));
136
+
City city = cities.insertAndFetch(City.builder()
137
+
.name("Sunnyvale")
138
+
.population(155_000)
139
+
.build());
133
140
134
141
// Insert a user that references the city
135
-
User user = users.insertAndFetch(newUser(null, "alice@example.com", "Alice", city));
142
+
User user = users.insertAndFetch(User.builder()
143
+
.email("alice@example.com")
144
+
.name("Alice")
145
+
.city(city)
146
+
.build());
136
147
```
137
148
138
149
The `insertAndFetch` method sends an INSERT statement, retrieves the auto-generated primary key, and returns a new record with the key populated.
@@ -237,7 +248,11 @@ With Spring's `@Transactional`:
237
248
@Transactional
238
249
publicUser createUser(String email, String name, City city) {
Copy file name to clipboardExpand all lines: website/versioned_docs/version-1.10.0/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ import TabItem from '@theme/TabItem';
23
23
24
24
## Why Storm?
25
25
26
-
Storm draws inspiration from established ORMs such as Hibernate, but is built from scratch around a clear design philosophy: capturing exactly what you want to do using the minimum amount of code, optimized for Kotlin and modern Java
26
+
Storm draws inspiration from established ORMs such as Hibernate, but is built from scratch around a clear design philosophy: capture intent using the minimum amount of code, optimized for Kotlin and modern Java.
27
27
28
28
**Storm's mission:** Make database development productive and enjoyable, with full developer control and high performance.
0 commit comments