diff --git a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt index 9eb1c86..bac32a1 100644 --- a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt +++ b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/model/Recipe.kt @@ -146,7 +146,7 @@ data class RecipeGroupInformation( @OneToMany(cascade = [CascadeType.ALL], fetch = FetchType.EAGER, orphanRemoval = true) @JoinColumn(name = "recipe_group_information_id") - var steps: Set? + var steps: MutableSet? ) data class RecipeStepsDto( @@ -230,7 +230,7 @@ fun recipeGroupInformation( id: Long? = null, group: EmployeeGroup = employeeGroup(), note: String? = null, - steps: Set? = setOf(), + steps: MutableSet? = mutableSetOf(), op: RecipeGroupInformation.() -> Unit = {} ) = RecipeGroupInformation(id, group, note, steps).apply(op) diff --git a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt index baf0049..0f35fe8 100644 --- a/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt +++ b/src/main/kotlin/dev/fyloz/colorrecipesexplorer/service/RecipeService.kt @@ -86,10 +86,15 @@ class RecipeServiceImpl( with(recipe.groupInformationForGroup(it.groupId)) { updatedGroupsInformation.add( this?.apply { - this.steps = it.steps + if (this.steps != null) { + this.steps!!.clear() + this.steps!!.addAll(it.steps) + } else { + this.steps = it.steps.toMutableSet() + } } ?: recipeGroupInformation( group = groupService.getById(it.groupId), - steps = it.steps + steps = it.steps.toMutableSet() ) ) } diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index 9226777..06d0241 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:mysql://172.66.1.1/updater +spring.datasource.url=jdbc:mysql://172.66.1.1/cre spring.datasource.username=root spring.datasource.password=pass spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver