EMSADM DDL identity to sequence 대응 완료

This commit is contained in:
Rinjae
2025-11-14 15:00:44 +09:00
parent ffc6f8b34b
commit eaac6f943a
5 changed files with 77 additions and 3 deletions
@@ -5,6 +5,7 @@ import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
@@ -18,7 +19,20 @@ public class PortalUserPrivacyAgreement extends Auditable implements Serializabl
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@GenericGenerator(
name = "ptl_user_privacy_policy_agreement_gen",
strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
parameters = {
@org.hibernate.annotations.Parameter(name = "sequence_name", value = "PTL_USER_PRIVACY_POLICY_AGREEMENT_SEQ"),
@org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
@org.hibernate.annotations.Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "ptl_user_privacy_policy_agreement_gen"
)
@Column(name = "id", nullable = false)
private Long id;
@@ -3,6 +3,8 @@ package com.eactive.apim.portal.portaluser.entity;
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +17,21 @@ public class UserPasswordHistory implements Serializable, com.eactive.eai.data.D
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", columnDefinition = "bigint")
@GenericGenerator(
name = "ptl_user_password_history_seq_gen",
strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "PTL_USER_PASSWORD_HISTORY_SEQ"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "ptl_user_password_history_seq_gen"
)
// @Column(name = "id", columnDefinition = "bigint")
@Column(name = "id", columnDefinition = "number(19)")
private Long id;
@Column(name = "user_id", length = 35, nullable = false)
@@ -0,0 +1,16 @@
package com.eactive.eai.rms.data;
public class PortalSchemaProviderHolder {
private static SchemaProvider provider;
public static void setProvider(SchemaProvider p) {
provider = p;
}
public static String getSchema() {
if (provider == null) {
throw new IllegalStateException("SchemaProvider not initialized!");
}
return provider.getSchema();
}
}
@@ -0,0 +1,5 @@
package com.eactive.eai.rms.data;
public interface SchemaProvider {
String getSchema();
}
@@ -0,0 +1,24 @@
package com.eactive.eai.rms.data.jpa;
import com.eactive.eai.rms.data.PortalSchemaProviderHolder;
import org.hibernate.MappingException;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type;
import java.util.Properties;
public class SchemaPrefixedSequenceGenerator extends SequenceStyleGenerator {
@Override
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
String raw = params.getProperty(SEQUENCE_PARAM);
if (!raw.contains(".")) {
String schema = PortalSchemaProviderHolder.getSchema();
params.setProperty(SEQUENCE_PARAM, schema + "." + raw);
}
super.configure(type, params, serviceRegistry);
}
}