Skip to content

Commit

Permalink
Brreg-stub hibernate 6 migrering
Browse files Browse the repository at this point in the history
#deploy-brreg-stub
  • Loading branch information
stigus committed Oct 20, 2023
1 parent 128f5f5 commit e7262f8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import static no.nav.brregstub.jpa.HibernateConstants.SEQUENCE_STYLE_GENERATOR;

@Entity
@Getter
Expand All @@ -12,7 +15,12 @@
public class HentRolle {

@Id
@GeneratedValue
@GeneratedValue(generator = "hentRolleIdGenerator")
@GenericGenerator(name = "hentRolleIdGenerator", strategy = SEQUENCE_STYLE_GENERATOR, parameters = {
@org.hibernate.annotations.Parameter(name = "sequence_name", value = "HENTROLLE_SEQ"),
@org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
@org.hibernate.annotations.Parameter(name = "increment_size", value = "1")
})
private Long id;

@NotNull(message = "orgnr must not be null")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import static no.nav.brregstub.jpa.HibernateConstants.SEQUENCE_STYLE_GENERATOR;

@Entity
@Getter
Expand All @@ -12,7 +15,12 @@
public class Rolleoversikt {

@Id
@GeneratedValue
@GeneratedValue(generator = "rolleOversiktIdGenerator")
@GenericGenerator(name = "rolleOversiktIdGenerator", strategy = SEQUENCE_STYLE_GENERATOR, parameters = {
@org.hibernate.annotations.Parameter(name = "sequence_name", value = "ROLLEOVERSIKT_SEQ"),
@org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
@org.hibernate.annotations.Parameter(name = "increment_size", value = "1")
})
private Long id;

@NotNull(message = "fnr must not be null")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package no.nav.brregstub.jpa;

import lombok.experimental.UtilityClass;

@UtilityClass
public class HibernateConstants {

public static final String SEQUENCE_STYLE_GENERATOR = "org.hibernate.id.enhanced.SequenceStyleGenerator";
}
7 changes: 4 additions & 3 deletions proxies/aareg-proxy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
}

java {
sourceCompatibility = JavaVersion.VERSION_21
}
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

0 comments on commit e7262f8

Please sign in to comment.