diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java index cdad62e7b..8a7b203b5 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java @@ -71,12 +71,16 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio private static final long serialVersionUID = 1L; @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds")) + @JoinColumn( + name = "distribution_set", nullable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds")) @NotNull private JpaDistributionSet distributionSet; @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn(name = "target", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ")) + @JoinColumn( + name = "target", updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ")) @NotNull private JpaTarget target; @@ -124,11 +128,15 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio private List actionStatus; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "rolloutgroup", updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup")) + @JoinColumn( + name = "rolloutgroup", updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup")) private JpaRolloutGroup rolloutGroup; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "rollout", updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout")) + @JoinColumn( + name = "rollout", updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout")) private JpaRollout rollout; @Column(name = "maintenance_cron_schedule", updatable = false, length = Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java index 0ba275a4d..4a12b4c57 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java @@ -58,7 +58,9 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements private long occurredAt; @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn(name = "action", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action")) + @JoinColumn( + name = "action", nullable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action")) @NotNull private JpaAction action; @@ -82,9 +84,14 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements @CascadeOnDelete @ElementCollection(fetch = FetchType.LAZY, targetClass = String.class) - @CollectionTable(name = "sp_action_status_messages", joinColumns = @JoinColumn(name = "action_status_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat"), updatable = false, nullable = false), indexes = { - @Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") }) - @Column(name = "detail_message", length = MESSAGE_ENTRY_LENGTH, nullable = false, updatable = false) + @CollectionTable( + name = "sp_action_status_messages", + joinColumns = @JoinColumn( + name = "action_status_id", insertable = false, updatable = false, 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") }) + @Column(name = "detail_message", length = MESSAGE_ENTRY_LENGTH, nullable = false, insertable = false, updatable = false) private List messages; @Column(name = "code", nullable = true, updatable = false) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index 54dd3d705..529d16c3a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -88,16 +88,30 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen @CascadeOnDelete @ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY) - @JoinTable(name = "sp_ds_module", joinColumns = { - @JoinColumn(name = "ds_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) }, inverseJoinColumns = { - @JoinColumn(name = "module_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) }) + @JoinTable( + name = "sp_ds_module", + joinColumns = { + @JoinColumn( + name = "ds_id", nullable = false, insertable = false, updatable = false, foreignKey = + @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) }, + inverseJoinColumns = { + @JoinColumn( + name = "module_id", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) }) private Set modules; @CascadeOnDelete @ManyToMany(targetEntity = JpaDistributionSetTag.class) - @JoinTable(name = "sp_ds_dstag", joinColumns = { - @JoinColumn(name = "ds", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) }, inverseJoinColumns = { - @JoinColumn(name = "TAG", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) }) + @JoinTable( + name = "sp_ds_dstag", + joinColumns = { + @JoinColumn( + name = "ds", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) }, + inverseJoinColumns = { + @JoinColumn( + name = "TAG", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) }) private Set tags; @ToString.Exclude diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java index 0db14927e..e29599466 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java @@ -159,9 +159,13 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw @JoinTable( name = "sp_target_target_tag", joinColumns = { - @JoinColumn(name = "target", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) }, + @JoinColumn( + name = "target", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) }, inverseJoinColumns = { - @JoinColumn(name = "tag", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag")) + @JoinColumn( + name = "tag", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag")) }) private Set tags; @@ -174,8 +178,8 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw @MapKeyColumn(name = "attribute_key", nullable = false, length = Target.CONTROLLER_ATTRIBUTE_KEY_SIZE) @CollectionTable( name = "sp_target_attributes", - joinColumns = { - @JoinColumn(name = "target_id", nullable = false, updatable = false) }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target")) + joinColumns = { @JoinColumn(name = "target_id", nullable = false, insertable = false, updatable = false) }, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target")) private Map controllerAttributes; @CascadeOnDelete diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetType.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetType.java index 2dc324968..09abe456b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetType.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetType.java @@ -53,9 +53,16 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType, @CascadeOnDelete @ManyToMany(targetEntity = JpaDistributionSetType.class) - @JoinTable(name = "sp_target_type_ds_type_relation", joinColumns = { - @JoinColumn(name = "target_type", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_target_type")) }, inverseJoinColumns = { - @JoinColumn(name = "distribution_set_type", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_ds_type")) }) + @JoinTable( + name = "sp_target_type_ds_type_relation", + joinColumns = { + @JoinColumn( + name = "target_type", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_target_type")) }, + inverseJoinColumns = { + @JoinColumn( + name = "distribution_set_type", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_type_relation_ds_type")) }) private Set distributionSetTypes; public JpaTargetType(final String key, final String name, final String description, final String colour) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroup.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroup.java index af5a57f06..1697fddf0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroup.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroup.java @@ -56,8 +56,8 @@ public class RolloutTargetGroup implements Serializable { @OneToMany(targetEntity = JpaAction.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }) @JoinColumns(value = { - @JoinColumn(name = "rolloutgroup", nullable = false, updatable = false, referencedColumnName = "rolloutGroup_Id"), - @JoinColumn(name = "target", nullable = false, updatable = false, referencedColumnName = "target_id") }) + @JoinColumn(name = "rolloutgroup", nullable = false, insertable = false, updatable = false, referencedColumnName = "rolloutGroup_Id"), + @JoinColumn(name = "target", nullable = false, insertable = false, updatable = false, referencedColumnName = "target_id") }) private List actions; /** diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java index b4838b35c..0dc3a4ddc 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java @@ -75,7 +75,7 @@ public interface DistributionSetRepository */ @Modifying @Transactional - @Query("update JpaDistributionSet d set d.deleted = 1 where d.id in :ids") + @Query("update JpaDistributionSet d set d.deleted = true where d.id in :ids") void deleteDistributionSet(@Param("ids") Long... ids); /**