diff --git a/backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/V2ImportLanguagesController.kt b/backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/V2ImportLanguagesController.kt index 9c3ea47ef1..b8f47d6cc6 100644 --- a/backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/V2ImportLanguagesController.kt +++ b/backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/V2ImportLanguagesController.kt @@ -228,7 +228,7 @@ class V2ImportLanguagesController( private fun checkImportLanguageInProject(languageId: Long): ImportLanguage { val language = importService.findLanguage(languageId) ?: throw NotFoundException() - val languageProjectId = language.file.import.project.id + val languageProjectId = language.file.importEntity.project.id if (languageProjectId != projectHolder.project.id) { throw BadRequestException(io.tolgee.constants.Message.IMPORT_LANGUAGE_NOT_FROM_PROJECT) } diff --git a/backend/app/src/test/kotlin/io/tolgee/repository/dataImport/ImportFileRepositoryTest.kt b/backend/app/src/test/kotlin/io/tolgee/repository/dataImport/ImportFileRepositoryTest.kt index 72ec124459..cd735cecfd 100644 --- a/backend/app/src/test/kotlin/io/tolgee/repository/dataImport/ImportFileRepositoryTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/repository/dataImport/ImportFileRepositoryTest.kt @@ -21,11 +21,11 @@ class ImportFileRepositoryTest : AbstractSpringTest() { fun `creates and saves and gets ImportFile entity`() { val import = createBaseImport() - ImportFile(import = import, name = "en.json").let { + ImportFile(importEntity = import, name = "en.json").let { importFileRepository.save(it).let { saved -> importFileRepository.getOne(saved.id).let { got -> assertThat(got.name).isEqualTo(it.name) - assertThat(got.import).isEqualTo(import) + assertThat(got.importEntity).isEqualTo(import) assertThat(got.id).isGreaterThan(0L) } } @@ -44,7 +44,7 @@ class ImportFileRepositoryTest : AbstractSpringTest() { builder.toString() } - ImportFile(import = import, name = longName).let { + ImportFile(importEntity = import, name = longName).let { assertThatExceptionOfType(ConstraintViolationException::class.java) .isThrownBy { importFileRepository.save(it) diff --git a/backend/data/build.gradle b/backend/data/build.gradle index 8933dee28b..4b2c51e426 100644 --- a/backend/data/build.gradle +++ b/backend/data/build.gradle @@ -246,8 +246,8 @@ ktlint { hibernate { enhancement { - enableDirtyTracking = false - enableAssociationManagement = false - enableExtendedEnhancement = false +// enableDirtyTracking = true +// enableAssociationManagement = false +// enableExtendedEnhancement = false } } diff --git a/backend/data/src/main/kotlin/io/tolgee/model/dataImport/Import.kt b/backend/data/src/main/kotlin/io/tolgee/model/dataImport/Import.kt index a4dd412826..6f433b5c8c 100644 --- a/backend/data/src/main/kotlin/io/tolgee/model/dataImport/Import.kt +++ b/backend/data/src/main/kotlin/io/tolgee/model/dataImport/Import.kt @@ -28,7 +28,7 @@ class Import( @ManyToOne(optional = false) lateinit var author: UserAccount - @OneToMany(mappedBy = "import", orphanRemoval = true) + @OneToMany(mappedBy = "importEntity", orphanRemoval = true) var files = mutableListOf() override var deletedAt: Date? = null diff --git a/backend/data/src/main/kotlin/io/tolgee/model/dataImport/ImportFile.kt b/backend/data/src/main/kotlin/io/tolgee/model/dataImport/ImportFile.kt index c5b7e41111..37cda0242b 100644 --- a/backend/data/src/main/kotlin/io/tolgee/model/dataImport/ImportFile.kt +++ b/backend/data/src/main/kotlin/io/tolgee/model/dataImport/ImportFile.kt @@ -8,6 +8,7 @@ import io.tolgee.model.dataImport.issues.paramTypes.FileIssueParamType import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Index +import jakarta.persistence.JoinColumn import jakarta.persistence.ManyToOne import jakarta.persistence.OneToMany import jakarta.persistence.Table @@ -26,7 +27,10 @@ class ImportFile( var name: String?, @field:ManyToOne(optional = false) @get:ManyToOne(optional = false) - val import: Import, + // It cannot be named "import", because with Hibernate 6.6 that fails to build + // It is probably some reserved keyword + @JoinColumn(name = "import_id") + val importEntity: Import, ) : StandardAuditModel() { @OneToMany(mappedBy = "file", orphanRemoval = true) var issues: MutableList = mutableListOf() diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportFileRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportFileRepository.kt index bb25056e9f..e3cbb8679e 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportFileRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportFileRepository.kt @@ -12,8 +12,8 @@ interface ImportFileRepository : JpaRepository { @Query( """ select f from ImportFile f - where f.import.project.id = :projectId - and f.import.author.id = :authorId + where f.importEntity.project.id = :projectId + and f.importEntity.author.id = :authorId and f.id = :id """, ) diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportKeyRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportKeyRepository.kt index 0a9ccc548c..a49729c4be 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportKeyRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportKeyRepository.kt @@ -17,7 +17,7 @@ interface ImportKeyRepository : JpaRepository { select distinct ik from ImportKey ik left join fetch ik.keyMeta km join fetch ik.file if - join fetch if.import im where im.id = :importId + join fetch if.importEntity im where im.id = :importId """, ) fun findAllByImport(importId: Long): List @@ -27,6 +27,6 @@ interface ImportKeyRepository : JpaRepository { @Query("""delete from ImportKey ik where ik.id in :ids""") fun deleteByIdIn(ids: List) - @Query("""select iik.id from ImportKey iik join iik.file if where if.import = :import""") + @Query("""select iik.id from ImportKey iik join iik.file if where if.importEntity = :import""") fun getAllIdsByImport(import: Import): List } diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportLanguageRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportLanguageRepository.kt index 8ca0629ff2..6c100da0f4 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportLanguageRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportLanguageRepository.kt @@ -49,7 +49,7 @@ LEFT JOIN il.existingLanguage el """ } - @Query("from ImportLanguage il join il.file if join if.import im where im.id = :importId") + @Query("from ImportLanguage il join il.file if join if.importEntity im where im.id = :importId") fun findAllByImport(importId: Long): List @Modifying @@ -60,7 +60,7 @@ LEFT JOIN il.existingLanguage el @Query( """ $VIEW_BASE_QUERY - WHERE f.import.id = :importId + WHERE f.importEntity.id = :importId $VIEW_GROUP_BY order by il.id """, @@ -74,7 +74,7 @@ LEFT JOIN il.existingLanguage el @Transactional @Query( """delete from ImportLanguage l where l.file in - (select f from ImportFile f where f.import = :import)""", + (select f from ImportFile f where f.importEntity = :import)""", ) fun deleteAllByImport(import: Import) @@ -92,7 +92,7 @@ LEFT JOIN il.existingLanguage el select distinct il.existingLanguage.id from ImportLanguage il join il.file if - where if.import.id = :importId + where if.importEntity.id = :importId and il.existingLanguage.id is not null """, ) diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportRepository.kt index bc1811295a..e4d94d5786 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportRepository.kt @@ -28,7 +28,7 @@ interface ImportRepository : JpaRepository { @Query( """ - select distinct if.namespace from ImportFile if where if.import.id = :importId + select distinct if.namespace from ImportFile if where if.importEntity.id = :importId """, ) fun getAllNamespaces(importId: Long): Set diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportTranslationRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportTranslationRepository.kt index 9b7eb4f5f3..2f57b8af10 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportTranslationRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/ImportTranslationRepository.kt @@ -45,12 +45,12 @@ interface ImportTranslationRepository : JpaRepository { from ImportTranslation it left join it.conflict itc join it.key ik - left join Namespace en on ik.file.namespace = en.name and en.project = ik.file.import.project - left join Key ek on it.key.name = ek.name and ek.project = it.key.file.import.project + left join Namespace en on ik.file.namespace = en.name and en.project = ik.file.importEntity.project + left join Key ek on it.key.name = ek.name and ek.project = it.key.file.importEntity.project and (ek.namespace = en or (ek.namespace is null and en is null)) left join ik.keyMeta ikm left join ek.keyMeta ekm - left join ImportSettings is on is.project = ik.file.import.project + left join ImportSettings is on is.project = ik.file.importEntity.project where (itc.id is not null or :onlyConflicts = false) and ((itc.id is not null and it.resolvedHash is null) or :onlyUnresolved = false) and it.language.id = :languageId @@ -76,7 +76,7 @@ interface ImportTranslationRepository : JpaRepository { @Transactional @Query( """delete from ImportTranslation it where it.key.id in - (select k.id from ImportKey k join k.file f where f.import = :import)""", + (select k.id from ImportKey k join k.file f where f.importEntity = :import)""", ) @Modifying fun deleteAllByImport(import: Import) @@ -97,7 +97,7 @@ interface ImportTranslationRepository : JpaRepository { join fetch it.language il join il.file if where if.needsParamConversion = true - and if.import.id = :importId + and if.importEntity.id = :importId """, ) fun findTranslationsForPlaceholderConversion(importId: Long): List diff --git a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/issues/ImportFileIssueParamRepository.kt b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/issues/ImportFileIssueParamRepository.kt index 3a72e2f897..625789197b 100644 --- a/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/issues/ImportFileIssueParamRepository.kt +++ b/backend/data/src/main/kotlin/io/tolgee/repository/dataImport/issues/ImportFileIssueParamRepository.kt @@ -16,7 +16,7 @@ interface ImportFileIssueParamRepository : JpaRepository { @Transactional @Query( """delete from ImportFileIssue ifi where ifi.file in - (select f from ImportFile f where f.import = :import)""", + (select f from ImportFile f where f.importEntity = :import)""", ) @Modifying fun deleteAllByImport(import: Import) diff --git a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt index 5c57d9bb35..ea896e6f03 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt @@ -203,7 +203,7 @@ class ImportService( if (importLanguage.existingLanguage == existingLanguage) { return } - val import = importLanguage.file.import + val import = importLanguage.file.importEntity Sentry.addBreadcrumb("Import ID: ${import.id}") val dataManager = ImportDataManager(applicationContext, import) val oldExistingLanguage = importLanguage.existingLanguage @@ -221,7 +221,7 @@ class ImportService( namespace: String?, ) { val file = findFile(projectId, authorId, fileId) ?: throw NotFoundException() - val import = file.import + val import = file.importEntity Sentry.addBreadcrumb("Import ID: ${import.id}") val dataManager = ImportDataManager(applicationContext, import) file.namespace = getSafeNamespace(namespace) @@ -290,7 +290,7 @@ class ImportService( left join fetch ik.keyMeta ikm left join fetch ikm.comments ikc join ik.file if - where if.import = :import + where if.importEntity = :import """, ) .setParameter("import", import) @@ -394,10 +394,10 @@ class ImportService( @Transactional fun deleteLanguage(language: ImportLanguage) { - val import = language.file.import + val import = language.file.importEntity this.importTranslationRepository.deleteAllByLanguage(language) this.importLanguageRepository.delete(language) - if (this.findLanguages(import = language.file.import).isEmpty()) { + if (this.findLanguages(import = language.file.importEntity).isEmpty()) { deleteImport(import) return } diff --git a/backend/data/src/main/kotlin/io/tolgee/service/key/KeyMetaService.kt b/backend/data/src/main/kotlin/io/tolgee/service/key/KeyMetaService.kt index 906b887d85..8eac42dea9 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/key/KeyMetaService.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/key/KeyMetaService.kt @@ -79,7 +79,7 @@ class KeyMetaService( join fetch ikm.importKey ik left join fetch ikm.comments ikc join ik.file if - where if.import = :import + where if.importEntity = :import """, ) .setParameter("import", import) diff --git a/gradle.properties b/gradle.properties index 88065c1e52..f337cd21c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ kotlinVersion=2.0.20 springBootVersion=3.3.3 springDocVersion=2.3.0 jjwtVersion=0.11.2 -hibernateVersion=6.5.2.Final +hibernateVersion=6.6.5.Final amazonAwsSdkVersion=2.20.8 springDependencyManagementVersion=1.0.11.RELEASE org.gradle.jvmargs=-Xmx6g -Dkotlin.daemon.jvm.options=-Xmx6g