Skip to content

Commit 7c38a1d

Browse files
authored
spring-boot: adjust Column (#31815)
1 parent 54e0bdd commit 7c38a1d

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

generators/spring-boot/templates/src/main/java/_package_/domain/AbstractAuditingEntity.java.ejs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ import java.io.Serial;
4444
import java.io.Serializable;
4545
import java.time.Instant;
4646
<%_ if (databaseTypeSql) { _%>
47+
<%_ if (reactive) { _%>
48+
import org.springframework.data.relational.core.mapping.Column;
49+
<%_ } else { _%>
4750
import jakarta.persistence.Column;
51+
<%_ } _%>
4852
<%_ } _%>
4953
<%_ if (databaseTypeSql && !reactive) { _%>
5054
import jakarta.persistence.EntityListeners;
@@ -71,7 +75,11 @@ public abstract class AbstractAuditingEntity<T> implements Serializable {
7175
@CreatedBy
7276
<%_ } _%>
7377
<%_ if (databaseTypeSql) { _%>
78+
<%_ if (reactive) { _%>
79+
@Column("created_by")
80+
<%_ } else { _%>
7481
@Column(name = "created_by", nullable = false, length = 50, updatable = false)
82+
<%_ } _%>
7583
<%_ } _%>
7684
<%_ if (databaseTypeMongodb) { _%>
7785
@Field("created_by")
@@ -86,7 +94,11 @@ public abstract class AbstractAuditingEntity<T> implements Serializable {
8694

8795
@CreatedDate
8896
<%_ if (databaseTypeSql) { _%>
97+
<%_ if (reactive) { _%>
98+
@Column("created_date")
99+
<%_ } else { _%>
89100
@Column(name = "created_date", updatable = false)
101+
<%_ } _%>
90102
<%_ } _%>
91103
<%_ if (databaseTypeMongodb) { _%>
92104
@Field("created_date")
@@ -103,7 +115,11 @@ public abstract class AbstractAuditingEntity<T> implements Serializable {
103115
@LastModifiedBy
104116
<%_ } _%>
105117
<%_ if (databaseTypeSql) { _%>
118+
<%_ if (reactive) { _%>
119+
@Column("last_modified_by")
120+
<%_ } else { _%>
106121
@Column(name = "last_modified_by", length = 50)
122+
<%_ } _%>
107123
<%_ } _%>
108124
<%_ if (databaseTypeMongodb) { _%>
109125
@Field("last_modified_by")
@@ -118,7 +134,11 @@ public abstract class AbstractAuditingEntity<T> implements Serializable {
118134

119135
@LastModifiedDate
120136
<%_ if (databaseTypeSql) { _%>
137+
<%_ if (reactive) { _%>
138+
@Column("last_modified_date")
139+
<%_ } else { _%>
121140
@Column(name = "last_modified_date")
141+
<%_ } _%>
122142
<%_ } _%>
123143
<%_ if (databaseTypeMongodb) { _%>
124144
@Field("last_modified_date")

generators/spring-boot/templates/src/main/java/_package_/domain/User.java.ejs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ public class <%= user.persistClass %><% if (generateSpringAuditor) { %> extends
158158
<%_ if (searchEngineElasticsearch && authenticationTypeOauth2) { _%>
159159
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
160160
<%_ } _%>
161+
<%_ if (reactive) { _%>
162+
@Column("id")
163+
<%_ } else { _%>
164+
@Column(name = "id")
165+
<%_ } _%>
161166
<%_ } else if (databaseTypeNeo4j) { _%>
162167
@Id
163168
<%_ if (!authenticationTypeOauth2) { _%>
@@ -191,8 +196,12 @@ public class <%= user.persistClass %><% if (generateSpringAuditor) { %> extends
191196
@NotNull
192197
@Pattern(regexp = Constants.LOGIN_REGEX)
193198
@Size(min = 1, max = 50)
194-
<%_ if (databaseTypeSql && !reactive) { _%>
195-
@Column(length = 50, unique = true, nullable = false)
199+
<%_ if (databaseTypeSql) { _%>
200+
<%_ if (reactive) { _%>
201+
@Column("login")
202+
<%_ } else { _%>
203+
@Column(name = "login", length = 50, unique = true, nullable = false)
204+
<%_ } _%>
196205
<%_ } _%>
197206
<%_ if (databaseTypeMongodb) { _%>
198207
@Indexed
@@ -262,8 +271,12 @@ public class <%= user.persistClass %><% if (generateSpringAuditor) { %> extends
262271

263272
@Email
264273
@Size(min = 5, max = 254)
265-
<%_ if (databaseTypeSql && !reactive) { _%>
266-
@Column(length = 254, unique = true)
274+
<%_ if (databaseTypeSql) { _%>
275+
<%_ if (reactive) { _%>
276+
@Column("email")
277+
<%_ } else { _%>
278+
@Column(name = "email", length = 254, unique = true)
279+
<%_ } _%>
267280
<%_ } _%>
268281
<%_ if (databaseTypeMongodb) { _%>
269282
@Indexed
@@ -272,8 +285,10 @@ public class <%= user.persistClass %><% if (generateSpringAuditor) { %> extends
272285

273286
<%_ if (databaseTypeSql) { _%>
274287
@NotNull
275-
<%_ if (!reactive) { _%>
276-
@Column(nullable = false)
288+
<%_ if (reactive) { _%>
289+
@Column("activated")
290+
<%_ } else { _%>
291+
@Column(name = "activated", nullable = false)
277292
<%_ } _%>
278293
<%_ } _%>
279294
private boolean activated = false;

0 commit comments

Comments
 (0)