diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt index 1c75639..0b9f74a 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt @@ -26,7 +26,7 @@ data class Mix( @ManyToOne val recipe: Recipe, - @ManyToOne(cascade = [CascadeType.PERSIST]) + @ManyToOne var mixType: MixType, @OneToMany(cascade = [CascadeType.ALL]) diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt index f4717f7..98fbb08 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt @@ -33,7 +33,7 @@ class MixServiceImpl( override fun save(entity: MixSaveDto): Mix { val recipe = recipeService.getById(entity.recipeId) val materialType = materialTypeService.getById(entity.materialTypeId) - val mixType = MixType(entity.name, materialType) + val mixType = mixTypeService.createForNameAndMaterialType(entity.name, materialType) var mix = save(mix(recipe = recipe, mixType = mixType)) val mixMaterials = diff --git a/src/main/resources/application-h2.properties b/src/main/resources/application-h2.properties index 33d00af..346ad2a 100644 --- a/src/main/resources/application-h2.properties +++ b/src/main/resources/application-h2.properties @@ -1,5 +1,5 @@ -#spring.datasource.url=jdbc:h2:mem:cre -spring.datasource.url=jdbc:h2:file:./workdir/recipes +spring.datasource.url=jdbc:h2:mem:cre +#spring.datasource.url=jdbc:h2:file:./workdir/recipes spring.datasource.username=sa spring.datasource.password=LWK4Y7TvEbNyhu1yCoG3 spring.h2.console.path=/dbconsole diff --git a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt index 79f13fd..405752b 100644 --- a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt +++ b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt @@ -56,6 +56,7 @@ class MixServiceTest : AbstractExternalModelServiceTest