Skip to content

Commit

Permalink
Use user.primaryKey.type consistently everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
gzsombor committed Aug 16, 2023
1 parent ad7a691 commit 6727088
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class User implements Serializable {
<%_ if (databaseType === 'couchbase') { _%>
@GeneratedValue(strategy = UNIQUE, delimiter = ID_DELIMITER)
<%_ } _%>
private <% if (authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %> id;
private <%= user.primaryKey.type %> id;

@NotNull
@Pattern(regexp = Constants.LOGIN_REGEX)
Expand Down Expand Up @@ -120,11 +120,11 @@ public class User implements Serializable {
@Column(name = "last_modified_date")
private Instant lastModifiedDate;

public <% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } else { %>String<% } %> getId() {
public <%= user.primaryKey.type %> getId() {
return id;
}

public void setId(<% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } else { %>String<% } %> id) {
public void setId(<%= user.primaryKey.type %> id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.time.Instant;
* Micronaut Data JPA repository for the {@link User} entity.
*/
@Repository
public interface UserRepository extends JpaRepository<User, <% if (authenticationType !== 'oauth2') { %>Long<% } else { %>String<% } %>> {
public interface UserRepository extends JpaRepository<User, <%= user.primaryKey.type %>> {

<%_ if (usesCache) { _%>
public static String USERS_CACHE = "usersByLogin";
Expand All @@ -39,7 +39,7 @@ public interface UserRepository extends JpaRepository<User, <% if (authenticatio
public Optional<User> findOneByEmailIgnoreCase(String email);

@EntityGraph(attributePaths = "authorities")
public Optional<User> findOneById(<% if (authenticationType !== 'oauth2') { %>Long<% } else { %>String<% } %> id);
public Optional<User> findOneById(<%= user.primaryKey.type %> id);

@EntityGraph(attributePaths = "authorities")
<%_ if (usesCache) { _%>
Expand All @@ -61,5 +61,5 @@ public interface UserRepository extends JpaRepository<User, <% if (authenticatio

public Page<User> findByLoginNotEqual(String login, Pageable pageable);

public void update(@Id <% if (authenticationType !== 'oauth2') { %>Long<% } else { %>String<% } %> id, Instant createdDate);
public void update(@Id <%= user.primaryKey.type %> id, Instant createdDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.util.stream.Collectors;
@Introspected
public class <%= asDto('AdminUser') %> {

private <%= userPkType %> id;
private <%= user.primaryKey.type %> id;

@NotBlank
@Pattern(regexp = Constants.LOGIN_REGEX)
Expand Down Expand Up @@ -75,11 +75,11 @@ public class <%= asDto('AdminUser') %> {
.collect(Collectors.toSet());
}

public <%= userPkType %> getId() {
public <%= user.primaryKey.type %> getId() {
return id;
}

public void setId(<%= userPkType %> id) {
public void setId(<%= user.primaryKey.type %> id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.util.stream.Collectors;
@Introspected
public class <%= asDto('User') %> {

private <%= userPkType %> id;
private <%= user.primaryKey.type %> id;
private String login;

<%_ if (databaseType !== 'no') { _%>
Expand All @@ -35,11 +35,11 @@ public class <%= asDto('User') %> {
}
<%_ } _%>
public <%= userPkType %> getId() {
public <%= user.primaryKey.type %> getId() {
return id;
}

public void setId(<%= userPkType %> id) {
public void setId(<%= user.primaryKey.type %> id) {
this.id = id;
}

Expand Down

0 comments on commit 6727088

Please sign in to comment.