Skip to content

Commit 443afb3

Browse files
committed
Refactor AuditorAwareImpl to ensure non-null SecurityContext; update User entity to simplify JoinColumn annotations; add package-info.java for bootstrap package with NullMarked annotation.
1 parent 2240f77 commit 443afb3

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

core/src/main/java/com/workastra/core/module/auditing/AuditorAwareImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AuditorAwareImpl implements AuditorAware<User> {
1313

1414
@Override
1515
public Optional<User> getCurrentAuditor() {
16-
return Optional.ofNullable(SecurityContextHolder.getContext())
16+
return Optional.of(SecurityContextHolder.getContext())
1717
.map(SecurityContext::getAuthentication)
1818
.filter(Authentication::isAuthenticated)
1919
.map(Authentication::getPrincipal)

core/src/main/java/com/workastra/core/module/security/model/User.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class User implements UserDetails, CredentialsContainer {
119119
private Instant createdAt;
120120

121121
@ManyToOne(fetch = FetchType.LAZY)
122-
@JoinColumn(name = "created_by", insertable = true, updatable = false)
122+
@JoinColumn(name = "created_by", updatable = false)
123123
@CreatedBy
124124
private User createdBy;
125125

@@ -128,15 +128,15 @@ public class User implements UserDetails, CredentialsContainer {
128128
private Instant updatedAt;
129129

130130
@ManyToOne(fetch = FetchType.LAZY)
131-
@JoinColumn(name = "updated_by", insertable = true, updatable = true)
131+
@JoinColumn(name = "updated_by")
132132
@LastModifiedBy
133133
private User updatedBy;
134134

135135
@Column
136136
private @Nullable Instant deletedAt;
137137

138138
@ManyToOne(fetch = FetchType.LAZY)
139-
@JoinColumn(name = "deleted_by", insertable = true, updatable = true)
139+
@JoinColumn(name = "deleted_by")
140140
private @Nullable User deletedBy;
141141

142142
@Override
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@NullMarked
2+
package com.workastra.iam.bootstrap;
3+
4+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)