-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed distributed axon scenario (add sequence per table + mapping for…
… bytea dialect + set hibernate defaults for preferred_instant_jdbc_type and preferred_uuid_jdbc_type) - WIP
- Loading branch information
1 parent
bafff6d
commit da557bf
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...c/main/kotlin/io/holunda/polyflow/example/infrastructure/jpa/NoToastPostgresSQLDialect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
package io.holunda.polyflow.example.infrastructure.jpa | ||
|
||
import mu.KLogging | ||
import org.hibernate.boot.model.TypeContributions | ||
import org.hibernate.dialect.PostgreSQLDialect | ||
import org.hibernate.service.ServiceRegistry | ||
import org.hibernate.type.SqlTypes | ||
import org.hibernate.type.descriptor.jdbc.BinaryJdbcType | ||
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl | ||
import java.sql.Types | ||
|
||
class NoToastPostgresSQLDialect : PostgreSQLDialect() { | ||
|
||
companion object : KLogging() | ||
|
||
override fun registerColumnTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) { | ||
logger.info { "Register postgres mappings for bytea." } | ||
super.registerColumnTypes(typeContributions, serviceRegistry) | ||
val ddlTypeRegistry = typeContributions.typeConfiguration.ddlTypeRegistry | ||
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.BLOB, "bytea", this)) | ||
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.CLOB, "bytea", this)) | ||
ddlTypeRegistry.addDescriptor(DdlTypeImpl(Types.NCLOB, "bytea", this)) | ||
} | ||
|
||
override fun columnType(sqlTypeCode: Int): String { | ||
return when (sqlTypeCode) { | ||
SqlTypes.BLOB -> "bytea" | ||
else -> super.columnType(sqlTypeCode) | ||
} | ||
} | ||
|
||
override fun castType(sqlTypeCode: Int): String { | ||
return when (sqlTypeCode) { | ||
SqlTypes.BLOB -> "bytea" | ||
else -> super.castType(sqlTypeCode) | ||
} | ||
} | ||
|
||
override fun contributeTypes(typeContributions: TypeContributions, serviceRegistry: ServiceRegistry) { | ||
super.contributeTypes(typeContributions, serviceRegistry) | ||
val jdbcTypeRegistry = typeContributions.typeConfiguration | ||
.jdbcTypeRegistry | ||
jdbcTypeRegistry.addDescriptor(Types.BLOB, BinaryJdbcType.INSTANCE) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...rocess-application/src/main/resources/db/migrations/V0_0_13__axon_sequences_per_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DROP SEQUENCE hibernate_sequence; | ||
|
||
CREATE SEQUENCE association_value_entry_seq START WITH 1 INCREMENT BY 50; | ||
|
||
CREATE SEQUENCE domain_event_entry_seq START WITH 1 INCREMENT BY 50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters