-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace JPA with JDBC because fuck JPA
- Loading branch information
Showing
13 changed files
with
77 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
package dev.vrba.dubs.domain; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.MappedProperty; | ||
import io.micronaut.data.annotation.sql.JoinColumn; | ||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
import lombok.*; | ||
|
||
@With | ||
@Getter | ||
@Entity(name = "channels") | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedEntity("channels") | ||
public class Channel { | ||
@Id | ||
@NonNull | ||
@Column(name = "id", nullable = false) | ||
@MappedProperty("id") | ||
private String id; | ||
|
||
@NonNull | ||
@Column(name = "name", nullable = false) | ||
@MappedProperty("name") | ||
private String name; | ||
|
||
@JoinColumn(name = "guild_id", referencedColumnName = "id") | ||
@ManyToOne(fetch = FetchType.EAGER, optional = false) | ||
private Guild guild; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
package dev.vrba.dubs.domain; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
|
||
import java.util.Set; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.MappedProperty; | ||
import lombok.*; | ||
|
||
@With | ||
@Getter | ||
@Entity(name = "guilds") | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedEntity("guilds") | ||
public class Guild { | ||
@Id | ||
@NonNull | ||
@Column(name = "id", nullable = false, updatable = false) | ||
@MappedProperty("id") | ||
private String id; | ||
|
||
@NonNull | ||
@Column(name = "name", nullable = false) | ||
@MappedProperty("name") | ||
private String name; | ||
|
||
@NonNull | ||
@Column(name = "icon_url", nullable = false) | ||
@MappedProperty("icon_url") | ||
private String icon; | ||
|
||
@NonNull | ||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "guild") | ||
private Set<Channel> channels; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,52 @@ | ||
package dev.vrba.dubs.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.Size; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.MappedProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.math.BigInteger; | ||
|
||
@Getter | ||
@Entity(name = "matches") | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedEntity("matches") | ||
public class Match { | ||
@Id | ||
@Column(name = "row_id") | ||
@MappedProperty("row_id") | ||
private Integer id; | ||
|
||
@Size(max = 64) | ||
@Column(name = "pattern_name", length = 64) | ||
@MappedProperty("pattern_name") | ||
private String patternName; | ||
|
||
@Column(name = "pattern_points") | ||
@MappedProperty("pattern_points") | ||
private Long patternPoints; | ||
|
||
@Column(name = "pattern_is_rare") | ||
@MappedProperty("pattern_is_rare") | ||
private Boolean patternIsRare; | ||
|
||
@Size(max = 32) | ||
@Column(name = "user_id", length = 32) | ||
@MappedProperty("user_id") | ||
private String userId; | ||
|
||
@Size(max = 128) | ||
@Column(name = "user_name", length = 128) | ||
@MappedProperty("user_name") | ||
private String userName; | ||
|
||
@Size(max = 32) | ||
@Column(name = "channel_id", length = 32) | ||
@MappedProperty("channel_id") | ||
private String channelId; | ||
|
||
@Size(max = 128) | ||
@Column(name = "channel_name", length = 128) | ||
@MappedProperty("channel_name") | ||
private String channelName; | ||
|
||
@Size(max = 32) | ||
@Column(name = "guild_id", length = 32) | ||
@MappedProperty("guild_id") | ||
private String guildId; | ||
|
||
@Size(max = 128) | ||
@Column(name = "guild_name", length = 128) | ||
@MappedProperty("guild_name") | ||
private String guildName; | ||
|
||
@Column(name = "count") | ||
@MappedProperty("count") | ||
private BigInteger count; | ||
} |
25 changes: 14 additions & 11 deletions
25
api/src/main/java/dev/vrba/dubs/domain/MatchedPattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,44 @@ | ||
package dev.vrba.dubs.domain; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import jakarta.persistence.*; | ||
import io.micronaut.data.annotation.GeneratedValue; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.MappedProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldNameConstants; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Entity(name = "matched_patterns") | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@MappedEntity("matched_patterns") | ||
public class MatchedPattern { | ||
@Id | ||
@NonNull | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false, updatable = false, insertable = false) | ||
@GeneratedValue() | ||
@MappedProperty("id") | ||
private Long id = null; | ||
|
||
@NonNull | ||
@Column(name = "channel_id", nullable = false) | ||
@MappedProperty("channel_id") | ||
private String channel; | ||
|
||
@NonNull | ||
@Column(name = "user_id", nullable = false) | ||
@MappedProperty("user_id") | ||
private String user; | ||
|
||
@NonNull | ||
@Column(name = "pattern_name", nullable = false) | ||
@MappedProperty("pattern_name") | ||
private String patternName; | ||
|
||
@NonNull | ||
@Column(name = "pattern_points", nullable = false) | ||
@MappedProperty("pattern_points") | ||
private long patternPoints; | ||
|
||
@NonNull | ||
@Column(name = "pattern_is_rare", nullable = false) | ||
@MappedProperty("pattern_is_rare") | ||
private boolean patternIsRare; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
package dev.vrba.dubs.domain; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.data.annotation.MappedProperty; | ||
import lombok.*; | ||
|
||
import java.math.BigInteger; | ||
|
||
@With | ||
@Getter | ||
@Entity(name = "users") | ||
@Setter | ||
@MappedEntity("users") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class User { | ||
@Id | ||
@NonNull | ||
@Column(name = "id", nullable = false, updatable = false) | ||
@MappedProperty("id") | ||
private String id; | ||
|
||
@NonNull | ||
@Column(name = "name", nullable = false) | ||
@MappedProperty("name") | ||
private String name; | ||
|
||
@NonNull | ||
@Column(name = "avatar_url", nullable = false) | ||
@MappedProperty("avatar_url") | ||
private String avatar; | ||
|
||
@NonNull | ||
@Column(name = "points", nullable = false) | ||
@MappedProperty("points") | ||
private BigInteger points; | ||
} |
5 changes: 3 additions & 2 deletions
5
api/src/main/java/dev/vrba/dubs/repository/ChannelRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package dev.vrba.dubs.repository; | ||
|
||
import dev.vrba.dubs.domain.Channel; | ||
import io.micronaut.data.annotation.Repository; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@Repository | ||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface ChannelRepository extends CrudRepository<Channel, String> { | ||
} |
5 changes: 3 additions & 2 deletions
5
api/src/main/java/dev/vrba/dubs/repository/GuildRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package dev.vrba.dubs.repository; | ||
|
||
import dev.vrba.dubs.domain.Guild; | ||
import io.micronaut.data.annotation.Repository; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@Repository | ||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface GuildRepository extends CrudRepository<Guild, String> { | ||
} |
5 changes: 3 additions & 2 deletions
5
api/src/main/java/dev/vrba/dubs/repository/MatchRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package dev.vrba.dubs.repository; | ||
|
||
import dev.vrba.dubs.domain.Match; | ||
import io.micronaut.data.annotation.Repository; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@Repository | ||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface MatchRepository extends CrudRepository<Match, Integer> { | ||
} |
5 changes: 3 additions & 2 deletions
5
api/src/main/java/dev/vrba/dubs/repository/MatchedPatternRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package dev.vrba.dubs.repository; | ||
|
||
import dev.vrba.dubs.domain.MatchedPattern; | ||
import io.micronaut.data.annotation.Repository; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@Repository | ||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface MatchedPatternRepository extends CrudRepository<MatchedPattern, Long> { | ||
} |
5 changes: 3 additions & 2 deletions
5
api/src/main/java/dev/vrba/dubs/repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package dev.vrba.dubs.repository; | ||
|
||
import dev.vrba.dubs.domain.User; | ||
import io.micronaut.data.annotation.Repository; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@Repository | ||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface UserRepository extends CrudRepository<User, String> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ flyway: | |
|
||
jpa: | ||
default: | ||
entity-scan: | ||
packages: dev.vrba.dubs.domain | ||
properties: | ||
hibernate: | ||
hbm2ddl: | ||
|