Fix/db refactoring rename (#2365)
* Refactor datbase - renaming Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com> * Final refactoring Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com> --------- Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -137,8 +137,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
this.repositoryProperties = repositoryProperties;
|
||||
|
||||
final String isDeleted = isPostgreSql(properties) ? "false" : "0";
|
||||
countArtifactQuery = "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countSoftwareModulesQuery = "select SUM(file_size) from sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countArtifactQuery = "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countSoftwareModulesQuery = "select SUM(file_size) from sp_artifact a INNER JOIN sp_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // it's not required on dmf/ddi only instances
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DistributionSetTypeElement implements Serializable {
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(
|
||||
name = "distribution_set_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_element"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_distribution_set_type"))
|
||||
private JpaDistributionSetType dsType;
|
||||
|
||||
@Getter
|
||||
@@ -56,7 +56,7 @@ public class DistributionSetTypeElement implements Serializable {
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(
|
||||
name = "software_module_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_smtype"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_type_element_software_module_type"))
|
||||
private JpaSoftwareModuleType smType;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -87,7 +87,7 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "distribution_set", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_distribution_set"))
|
||||
@NotNull
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "target", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target"))
|
||||
@NotNull
|
||||
private JpaTarget target;
|
||||
|
||||
@@ -135,8 +135,8 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(
|
||||
name = "rolloutgroup", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
||||
name = "rollout_group", updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout_group"))
|
||||
private JpaRolloutGroup rolloutGroup;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(
|
||||
name = "action", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_status_action"))
|
||||
@NotNull
|
||||
private JpaAction action;
|
||||
|
||||
@@ -82,9 +82,9 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
||||
@CollectionTable(
|
||||
name = "sp_action_status_messages",
|
||||
joinColumns = @JoinColumn(
|
||||
name = "action_status_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat")),
|
||||
indexes = { @Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") })
|
||||
name = "action_status", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_status_messages_action_status")),
|
||||
indexes = { @Index(name = "fk_action_status_messages_action_status", columnList = "action_status") })
|
||||
@Column(name = "detail_message", length = MESSAGE_ENTRY_LENGTH, nullable = false)
|
||||
private List<String> messages;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Art
|
||||
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST }, fetch = FetchType.LAZY)
|
||||
@JoinColumn(
|
||||
name = "software_module", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_assigned_sm"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_artifact_software_module"))
|
||||
private JpaSoftwareModule softwareModule;
|
||||
|
||||
@Column(name = "provided_file_name", length = 256, updatable = false)
|
||||
|
||||
@@ -37,7 +37,9 @@ public class JpaAutoConfirmationStatus extends AbstractJpaTenantAwareBaseEntity
|
||||
|
||||
// actually it is OneToOne - but lazy loading is not supported for OneToOne (at least for hibernate 6.6.2)
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "target_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_auto_conf"))
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_conf_status_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
@Column(name = "initiator", length = USERNAME_FIELD_LENGTH)
|
||||
|
||||
@@ -62,7 +62,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_distribution_set",
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distrib_set") },
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distribution_set") },
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,complete"),
|
||||
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
||||
@@ -75,40 +75,38 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String DELETED_PROPERTY = "deleted";
|
||||
|
||||
@Setter
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = JpaDistributionSetType.class)
|
||||
@JoinColumn(
|
||||
name = "ds_id", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
||||
name = "ds_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_distribution_set_ds_type"))
|
||||
@NotNull
|
||||
private DistributionSetType type;
|
||||
|
||||
@ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "sp_ds_module",
|
||||
name = "sp_ds_sm",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "ds_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_sm_ds_id")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "module_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||
name = "sm_id", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_sm_sm_id")) })
|
||||
private Set<SoftwareModule> modules = new HashSet<>();
|
||||
|
||||
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
|
||||
@JoinTable(
|
||||
name = "sp_ds_dstag",
|
||||
name = "sp_ds_tag",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "ds", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_tag_ds")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "TAG", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||
name = "tag", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_tag_tag")) })
|
||||
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||
|
||||
@ToString.Exclude
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JpaDistributionSetMetadata extends AbstractJpaMetaData implements D
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "ds_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
||||
@JoinColumn(name = "ds", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_metadata_ds"))
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
public JpaDistributionSetMetadata(final String key, final String value) {
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor needed for JPA entities.
|
||||
@Entity
|
||||
@Table(name = "sp_distributionset_tag",
|
||||
@Table(name = "sp_distribution_set_tag",
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_distribution_set_tag_01", columnList = "tenant,name") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_ds_tag"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_distribution_set_tag"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
|
||||
|
||||
@@ -49,8 +49,8 @@ import org.springframework.util.CollectionUtils;
|
||||
@Table(name = "sp_distribution_set_type", indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_type_01", columnList = "tenant,deleted"),
|
||||
@Index(name = "sp_idx_distribution_set_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"),
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") })
|
||||
@UniqueConstraint(columnNames = { "tenant", "type_key"}, name = "uk_sp_distribution_set_type_type_key"),
|
||||
@UniqueConstraint(columnNames = { "tenant", "name" }, name = "uk_sp_distribution_set_type_name") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetType extends AbstractJpaTypeEntity implements DistributionSetType, EventAwareEntity {
|
||||
|
||||
@@ -81,7 +81,9 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
|
||||
@JoinColumn(
|
||||
name = "distribution_set", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_distribution_set"))
|
||||
@NotNull
|
||||
private JpaDistributionSet distributionSet;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor needed for JPA entities.
|
||||
@Entity
|
||||
@Table(name = "sp_rolloutgroup", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout", "tenant" }, name = "uk_rolloutgroup"))
|
||||
@Table(name = "sp_rollout_group", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout", "tenant" }, name = "uk_rollout_group"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup, EventAwareEntity {
|
||||
@@ -56,7 +56,9 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "rollout", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout"))
|
||||
@JoinColumn(
|
||||
name = "rollout", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_group_rollout"))
|
||||
private JpaRollout rollout;
|
||||
|
||||
@Setter
|
||||
@@ -65,15 +67,16 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
||||
@Convert(converter = RolloutGroupStatusConverter.class)
|
||||
private RolloutGroupStatus status = RolloutGroupStatus.CREATING;
|
||||
|
||||
@OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST,
|
||||
CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
||||
@OneToMany(
|
||||
mappedBy = "rolloutGroup", fetch = FetchType.LAZY,
|
||||
cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
||||
private List<RolloutTargetGroup> rolloutTargetGroup;
|
||||
|
||||
// No foreign key to avoid to many nested cascades on delete which some DBs cannot handle
|
||||
@Setter
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(name = "parent_id")
|
||||
@JoinColumn(name = "parent")
|
||||
private JpaRolloutGroup parent;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -55,12 +55,12 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Getter
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_base_software_module",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "module_type", "name", "version", "tenant" }, name = "uk_base_sw_mod"),
|
||||
@Table(name = "sp_software_module",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "sm_type", "name", "version", "tenant" }, name = "uk_software_module"),
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_base_sw_module_01", columnList = "tenant,deleted,name,version"),
|
||||
@Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"),
|
||||
@Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") })
|
||||
@Index(name = "sp_idx_software_module_01", columnList = "tenant,deleted,name,version"),
|
||||
@Index(name = "sp_idx_software_module_02", columnList = "tenant,deleted,sm_type"),
|
||||
@Index(name = "sp_idx_software_module_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "SoftwareModule.artifacts", attributeNodes = { @NamedAttributeNode("artifacts") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
@@ -73,8 +73,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
||||
|
||||
@Setter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "module_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_module_type"))
|
||||
@JoinColumn(name = "sm_type", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_software_module_sm_type"))
|
||||
@NotNull
|
||||
private JpaSoftwareModuleType type;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
@ToString(callSuper = true)
|
||||
@IdClass(SwMetadataCompositeKey.class)
|
||||
@Entity
|
||||
@Table(name = "sp_sw_metadata")
|
||||
@Table(name = "sp_sm_metadata")
|
||||
public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements SoftwareModuleMetadata {
|
||||
|
||||
@Serial
|
||||
@@ -46,7 +46,7 @@ public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements So
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "sw_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||
@JoinColumn(name = "sm", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_sm_metadata_sm"))
|
||||
private JpaSoftwareModule softwareModule;
|
||||
|
||||
@Column(name = "target_visible")
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Table(name = "sp_software_module_type", indexes = {
|
||||
@Index(name = "sp_idx_software_module_type_01", columnList = "tenant,deleted"),
|
||||
@Index(name = "sp_idx_software_module_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"),
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") })
|
||||
@UniqueConstraint(columnNames = { "tenant", "type_key" }, name = "uk_sp_software_module_type_type_key"),
|
||||
@UniqueConstraint(columnNames = { "tenant", "name" }, name = "uk_sp_software_module_type_name") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaSoftwareModuleType extends AbstractJpaTypeEntity implements SoftwareModuleType, EventAwareEntity {
|
||||
|
||||
@@ -82,7 +82,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
|
||||
@Index(name = "sp_idx_target_05", columnList = "tenant,last_modified_at"),
|
||||
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "controller_id", "tenant" }, name = "uk_tenant_controller_id"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "controller_id", "tenant" }, name = "uk_target_controller_id"))
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(name = "Target.details", attributeNodes = {
|
||||
@NamedAttributeNode("targetType"),
|
||||
@@ -173,11 +173,11 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_target_tag_target")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "tag", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag"))
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_target_tag_tag"))
|
||||
})
|
||||
private Set<TargetTag> tags;
|
||||
|
||||
@@ -186,8 +186,8 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
||||
@ElementCollection
|
||||
@CollectionTable(
|
||||
name = "sp_target_attributes",
|
||||
joinColumns = { @JoinColumn(name = "target_id", nullable = false) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||
joinColumns = { @JoinColumn(name = "target", nullable = false) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_attributes_target"))
|
||||
@Column(name = "attribute_value", length = Target.CONTROLLER_ATTRIBUTE_VALUE_SIZE)
|
||||
@MapKeyColumn(name = "attribute_key", length = Target.CONTROLLER_ATTRIBUTE_KEY_SIZE)
|
||||
private Map<String, String> controllerAttributes;
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Entity
|
||||
@Table(
|
||||
name = "sp_target_filter_query",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_filter_query"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery, EventAwareEntity {
|
||||
@@ -65,23 +65,25 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
|
||||
private String query;
|
||||
|
||||
@ManyToOne(optional = true, fetch = FetchType.LAZY, targetEntity = JpaDistributionSet.class)
|
||||
@JoinColumn(name = "auto_assign_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_filter_auto_assign_ds"))
|
||||
@JoinColumn(
|
||||
name = "auto_assign_distribution_set",
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_filter_query_auto_assign_distribution_set"))
|
||||
private JpaDistributionSet autoAssignDistributionSet;
|
||||
|
||||
@Column(name = "auto_assign_action_type", nullable = true)
|
||||
@Column(name = "auto_assign_action_type")
|
||||
@Convert(converter = JpaAction.ActionTypeConverter.class)
|
||||
private ActionType autoAssignActionType;
|
||||
|
||||
@Column(name = "auto_assign_weight", nullable = true)
|
||||
@Column(name = "auto_assign_weight")
|
||||
private Integer autoAssignWeight;
|
||||
|
||||
@Column(name = "auto_assign_initiated_by", nullable = true, length = USERNAME_FIELD_LENGTH)
|
||||
@Column(name = "auto_assign_initiated_by", length = USERNAME_FIELD_LENGTH)
|
||||
private String autoAssignInitiatedBy;
|
||||
|
||||
@Column(name = "confirmation_required")
|
||||
private boolean confirmationRequired;
|
||||
|
||||
@Column(name = "access_control_context", nullable = true)
|
||||
@Column(name = "access_control_context")
|
||||
private String accessControlContext;
|
||||
|
||||
public JpaTargetFilterQuery(final String name, final String query, final DistributionSet autoAssignDistributionSet,
|
||||
|
||||
@@ -43,7 +43,9 @@ public class JpaTargetMetadata extends AbstractJpaMetaData implements TargetMeta
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_target"))
|
||||
@JoinColumn(
|
||||
name = "target", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_metadata_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,9 +30,12 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@ToString(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "sp_target_tag", indexes = { @Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_target_tag_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_targ_tag"))
|
||||
@Table(
|
||||
name = "sp_target_tag",
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_target_tag_01", columnList = "tenant,name") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_tag"))
|
||||
public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Entity
|
||||
@Table(name = "sp_target_type", indexes = {
|
||||
@Index(name = "sp_idx_target_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_type_name") })
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_target_name") })
|
||||
@SuppressWarnings("java:S2160") // the super class equals/hashcode shall be used
|
||||
public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType, EventAwareEntity {
|
||||
|
||||
@@ -51,15 +51,15 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
|
||||
|
||||
@ManyToMany(targetEntity = JpaDistributionSetType.class)
|
||||
@JoinTable(
|
||||
name = "sp_target_type_ds_type_relation",
|
||||
name = "sp_target_type_ds_type",
|
||||
joinColumns = {
|
||||
@JoinColumn(
|
||||
name = "target_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_target_type")) },
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_ds_type_target_type")) },
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(
|
||||
name = "distribution_set_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_ds_type")) })
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_ds_type_distribution_set_type")) })
|
||||
private Set<DistributionSetType> distributionSetTypes = new HashSet<>();
|
||||
|
||||
public JpaTargetType(final String key, final String name, final String description, final String colour) {
|
||||
|
||||
@@ -35,8 +35,9 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Setter
|
||||
@Getter
|
||||
@Entity
|
||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||
"tenant" }, name = "uk_tenant_key"))
|
||||
@Table(
|
||||
name = "sp_tenant_configuration",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key", "tenant" }, name = "uk_tenant_configuration"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration, EventAwareEntity {
|
||||
|
||||
@@ -44,9 +44,10 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@Setter
|
||||
@Getter
|
||||
@Table(name = "sp_tenant", indexes = {
|
||||
@Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenantmd_tenant") })
|
||||
@Table(
|
||||
name = "sp_tenant",
|
||||
indexes = { @Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") },
|
||||
uniqueConstraints = { @UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenant") })
|
||||
@NamedEntityGraph(name = "TenantMetaData.withDetails", attributeNodes = { @NamedAttributeNode("defaultDsType") })
|
||||
@Entity
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@@ -62,7 +63,9 @@ public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMe
|
||||
private String tenant;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "default_ds_type", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_tenant_md_default_ds_type"))
|
||||
@JoinColumn(
|
||||
name = "default_ds_type", nullable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_sp_tenant_default_ds_type"))
|
||||
private JpaDistributionSetType defaultDsType;
|
||||
|
||||
public JpaTenantMetaData(final DistributionSetType defaultDsType, final String tenant) {
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
@IdClass(RolloutTargetGroupId.class)
|
||||
@Entity
|
||||
@Table(name = "sp_rollouttargetgroup")
|
||||
@Table(name = "sp_rollout_target_group")
|
||||
public class RolloutTargetGroup implements Serializable {
|
||||
|
||||
@Serial
|
||||
@@ -44,20 +44,20 @@ public class RolloutTargetGroup implements Serializable {
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, targetEntity = JpaRolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(name = "rolloutGroup_Id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_group"))
|
||||
@JoinColumn(name = "rollout_group", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_target_group_rollout_group"))
|
||||
private JpaRolloutGroup rolloutGroup;
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, targetEntity = JpaTarget.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumn(
|
||||
name = "target_id", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollouttargetgroup_target"))
|
||||
name = "target", nullable = false, updatable = false,
|
||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rollout_target_group_target"))
|
||||
private JpaTarget target;
|
||||
|
||||
@OneToMany(targetEntity = JpaAction.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||
@JoinColumns(value = {
|
||||
@JoinColumn(name = "rolloutgroup", nullable = false, insertable = false, updatable = false, referencedColumnName = "rolloutGroup_Id"),
|
||||
@JoinColumn(name = "target", nullable = false, insertable = false, updatable = false, referencedColumnName = "target_id") })
|
||||
@JoinColumn(name = "rollout_group", nullable = false, insertable = false, updatable = false, referencedColumnName = "rollout_group"),
|
||||
@JoinColumn(name = "target", nullable = false, insertable = false, updatable = false, referencedColumnName = "target") })
|
||||
private List<JpaAction> actions;
|
||||
|
||||
public RolloutTargetGroup(final RolloutGroup rolloutGroup, final Target target) {
|
||||
|
||||
@@ -54,8 +54,8 @@ public interface RolloutGroupRepository extends BaseEntityRepository<JpaRolloutG
|
||||
* @param status the status of the rolloutgroups
|
||||
* @return The child {@link RolloutGroup}s in a specific status
|
||||
*/
|
||||
@Query("SELECT g FROM JpaRolloutGroup g WHERE g.parent.id=:rolloutGroupId and g.status=:status")
|
||||
List<JpaRolloutGroup> findByParentIdAndStatus(@Param("rolloutGroupId") long rolloutGroupId, @Param("status") RolloutGroupStatus status);
|
||||
@Query("SELECT g FROM JpaRolloutGroup g WHERE g.parent.id=:rollout_group and g.status=:status")
|
||||
List<JpaRolloutGroup> findByParentIdAndStatus(@Param("rollout_group") long rolloutGroupId, @Param("status") RolloutGroupStatus status);
|
||||
|
||||
/**
|
||||
* Updates all {@link RolloutGroup#getStatus()} of children for given parent.
|
||||
|
||||
Reference in New Issue
Block a user