Skip to content

Commit

Permalink
HSEARCH-4403 Remove payload type configuration property
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Sep 20, 2023
1 parent 3c83c75 commit a8ac419
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 252 deletions.
13 changes: 0 additions & 13 deletions documentation/src/main/asciidoc/migration/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,6 @@ Other databases:
* MSSQL: no migration required. Type of the `payload` is `varbinary(max)` in both cases.
* H2: no migration required. Type of the `payload` is `blob` in both cases.

[NOTE]
====
In case database migration cannot be performed immediately when upgrading to a new version of Hibernate Search,
a pair of configuration properties is available:
[source]
----
hibernate.search.coordination.entity.mapping.agent.payload_type=materialized_blob
hibernate.search.coordination.entity.mapping.outboxevent.payload_type=materialized_blob
----
Keep in mind that these properties are temporary, to help with the migration,
and will be removed in the future versions of Hibernate Search.
====

If you were using Hibernate Search 6.2 with Hibernate ORM 5, i.e. using regular Hibernate Search artifacts and not `-orm6`/`-jakarta` ones
this upgrade will also mean the upgrade of Hibernate ORM to 6.3. Doing so will lead to a potential type mismatch when using Hibernate ORM's schema validation.
To prevent that, `id` column types can be updated from `varchar` to `char` where applicable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.TestingOutboxPollingInternalConfigurer;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.avro.impl.EventPayloadSerializationUtils;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.cfg.HibernateOrmMapperOutboxPollingSettings;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.cfg.PayloadType;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.cfg.impl.HibernateOrmMapperOutboxPollingImplSettings;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.Agent;
import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.OutboxPollingAgentAdditionalJaxbMappingProducer;
Expand All @@ -51,8 +50,6 @@
import org.junit.Rule;
import org.junit.Test;

import org.apache.logging.log4j.Level;

public class OutboxPollingCustomEntityMappingIT {

private static final String CUSTOM_SCHEMA = "CUSTOM_SCHEMA";
Expand Down Expand Up @@ -392,91 +389,6 @@ public void validMappingWithCustomFailingUuidGenerator() {
);
}

@Test
public void validMappingWithDefaultPayloadType() {
testPayloadType( null );
}

@Test
public void validMappingWithExplicitDefaultPayloadType() {
testPayloadType( PayloadType.LONG32VARBINARY );
}

@Test
@SuppressWarnings("deprecation")
public void validMappingWithNonDefaultPayloadType() {
testPayloadType( PayloadType.MATERIALIZED_BLOB );
}

@SuppressWarnings("deprecation")
private void testPayloadType(PayloadType payloadType) {
KeysStatementInspector statementInspector = new KeysStatementInspector();

backendMock.expectAnySchema( IndexedEntity.INDEX );
OrmSetupHelper.SetupContext setupContext = ormSetupHelper.start()
.withProperty(
HibernateOrmMapperOutboxPollingImplSettings.COORDINATION_INTERNAL_CONFIGURER,
new TestingOutboxPollingInternalConfigurer().outboxEventFilter( eventFilter )
)
// Allow ORM to create schema as we want to use non-default for this testcase:
.withProperty( "jakarta.persistence.create-database-schemas", true )
.withProperty( "hibernate.show_sql", true )
.withProperty( "hibernate.format_sql", true )
.withProperty( "hibernate.session_factory.statement_inspector", statementInspector );

if ( payloadType != null ) {
setupContext
.withProperty(
HibernateOrmMapperOutboxPollingSettings.COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE,
payloadType
)
.withProperty(
HibernateOrmMapperOutboxPollingSettings.COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE,
payloadType
);
logged.expectEvent(
Level.WARN,
"Configuration property `hibernate.search.coordination.entity.mapping.outboxevent.payload_type` is deprecated and will be removed in the future versions of Hibernate Search",
"This property is only to help with the schema migration and should not be used as a long term solution"
);
logged.expectEvent(
Level.WARN,
"Configuration property `hibernate.search.coordination.entity.mapping.agent.payload_type` is deprecated and will be removed in the future versions of Hibernate Search",
"This property is only to help with the schema migration and should not be used as a long term solution"
);
}
sessionFactory = setupContext.setup( IndexedEntity.class );

backendMock.verifyExpectationsMet();

int id = 1;
with( sessionFactory ).runInTransaction( session -> {
IndexedEntity entity = new IndexedEntity();
entity.setId( id );
entity.setIndexedField( "value for the field" );
session.persist( entity );

backendMock.expectWorks( IndexedEntity.INDEX )
.add( "1", f -> f.field( "indexedField", "value for the field" ) );
} );

await().untilAsserted( () -> {
with( sessionFactory ).runInTransaction( session -> {
assertEventPayload( session );
assertAgentPayload( session );
} );
} );
// The events were hidden until now, to ensure they were not processed in separate batches.
// Make them visible to Hibernate Search now.
eventFilter.showAllEventsUpToNow( sessionFactory );
eventFilter.awaitUntilNoMoreVisibleEvents( sessionFactory );

backendMock.verifyExpectationsMet();

assertThat( statementInspector.countByKey( ORIGINAL_OUTBOX_EVENT_TABLE_NAME ) ).isPositive();
assertThat( statementInspector.countByKey( ORIGINAL_AGENT_TABLE_NAME ) ).isPositive();
}

private void assertEventUUIDVersion(Session session, int expectedVersion) {
List<OutboxEvent> events = eventFilter.findOutboxEventsNoFilter( session );
assertThat( events )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,25 +428,6 @@ private HibernateOrmMapperOutboxPollingSettings() {
public static final String COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE =
PREFIX + Radicals.COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE;

/**
* The name of the {@link org.hibernate.type.SqlTypes SQL type} used for representing the payload in the outbox event table.
* <p>
* Supported values are:
* <ul>
* <li>{@link PayloadType#MATERIALIZED_BLOB}, used in previous versions of Hibernate Search.</li>
* <li>{@link PayloadType#LONG32VARBINARY}, the new default and the value that will be used moving forward.</li>
* </ul>
* Only available when {@value HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@value HibernateOrmMapperOutboxPollingSettings#COORDINATION_STRATEGY_NAME}.
* <p>
* The default value is {@link Defaults#COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE}.
* @deprecated The setting is only available to help migrate existing applications to the current version of Hibernate Search.
* This setting will be removed in the future releases.
*/
@Deprecated
public static final String COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE =
PREFIX + Radicals.COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE;

/**
* The database catalog to use for the agent table.
* <p>
Expand Down Expand Up @@ -507,26 +488,6 @@ private HibernateOrmMapperOutboxPollingSettings() {
public static final String COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE =
PREFIX + Radicals.COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE;

/**
* The name of the {@link org.hibernate.type.SqlTypes SQL type} used for representing the payload in the agent table.
* <p>
* Supported values are:
* <ul>
* <li>{@link PayloadType#MATERIALIZED_BLOB}, used in previous versions of Hibernate Search.</li>
* <li>{@link PayloadType#LONG32VARBINARY}, the new default and the value that will be used moving forward.</li>
* </ul>
* Only available when {@value HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@value HibernateOrmMapperOutboxPollingSettings#COORDINATION_STRATEGY_NAME}.
* <p>
* The default value is {@link Defaults#COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE}.
* @deprecated The setting is only available to help migrate existing applications to the current version of Hibernate Search.
* This setting will be removed in the future releases.
*/
@Deprecated
public static final String COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE =
PREFIX + Radicals.COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE;


/**
* Configuration property keys without the {@link #PREFIX prefix}.
*/
Expand Down Expand Up @@ -573,9 +534,6 @@ private Radicals() {
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_OUTBOXEVENT_UUID_GEN_STRATEGY;
public static final String COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE =
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE;
@Deprecated
public static final String COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE =
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE;
public static final String COORDINATION_ENTITY_MAPPING_AGENT_CATALOG =
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_AGENT_CATALOG;
public static final String COORDINATION_ENTITY_MAPPING_AGENT_SCHEMA =
Expand All @@ -586,9 +544,6 @@ private Radicals() {
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_AGENT_UUID_GEN_STRATEGY;
public static final String COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE =
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_AGENT_UUID_TYPE;
@Deprecated
public static final String COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE =
COORDINATION_PREFIX + CoordinationRadicals.ENTITY_MAPPING_AGENT_PAYLOAD_TYPE;
}

/**
Expand Down Expand Up @@ -623,17 +578,13 @@ private CoordinationRadicals() {
public static final String ENTITY_MAPPING_AGENT_CATALOG = ENTITY_MAPPING_AGENT_PREFIX + "catalog";
public static final String ENTITY_MAPPING_AGENT_UUID_GEN_STRATEGY = ENTITY_MAPPING_AGENT_PREFIX + "uuid_gen_strategy";
public static final String ENTITY_MAPPING_AGENT_UUID_TYPE = ENTITY_MAPPING_AGENT_PREFIX + "uuid_type";
@Deprecated
public static final String ENTITY_MAPPING_AGENT_PAYLOAD_TYPE = ENTITY_MAPPING_AGENT_PREFIX + "payload_type";
public static final String ENTITY_MAPPING_OUTBOXEVENT_PREFIX = ENTITY_MAPPING_PREFIX + "outboxevent.";
public static final String ENTITY_MAPPING_OUTBOXEVENT_TABLE = ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "table";
public static final String ENTITY_MAPPING_OUTBOXEVENT_SCHEMA = ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "schema";
public static final String ENTITY_MAPPING_OUTBOXEVENT_CATALOG = ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "catalog";
public static final String ENTITY_MAPPING_OUTBOXEVENT_UUID_GEN_STRATEGY =
ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "uuid_gen_strategy";
public static final String ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE = ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "uuid_type";
@Deprecated
public static final String ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE = ENTITY_MAPPING_OUTBOXEVENT_PREFIX + "payload_type";
}

/**
Expand Down Expand Up @@ -664,16 +615,12 @@ private Defaults() {
public static final UuidGenerationStrategy COORDINATION_ENTITY_MAPPING_AGENT_UUID_GEN_STRATEGY =
UuidGenerationStrategy.AUTO;
public static final String COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE = "default";
@Deprecated
public static final PayloadType COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE = PayloadType.LONG32VARBINARY;

// Must not be longer than 20 characters, so that the generator does not exceed the 30 characters for Oracle11g
public static final String COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_TABLE = HSEARCH_PREFIX + "OUTBOX_EVENT";
public static final UuidGenerationStrategy COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_UUID_GEN_STRATEGY =
UuidGenerationStrategy.AUTO;
public static final String COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_UUID_TYPE = "default";
@Deprecated
public static final PayloadType COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_PAYLOAD_TYPE = PayloadType.LONG32VARBINARY;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ private HibernateOrmMapperOutboxPollingSpiSettings() {
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_SCHEMA},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_TABLE},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_GEN_STRATEGY},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_PAYLOAD_TYPE}.
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_OUTBOXEVENT_UUID_TYPE}.
* An exception ({@link org.hibernate.search.util.common.SearchException} will be thrown in case of such misconfiguration.
*/
public static final String OUTBOXEVENT_ENTITY_MAPPING = PREFIX + Radicals.OUTBOXEVENT_ENTITY_MAPPING;
Expand All @@ -65,8 +64,7 @@ private HibernateOrmMapperOutboxPollingSpiSettings() {
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_SCHEMA},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_TABLE},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_UUID_GEN_STRATEGY},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE},
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_PAYLOAD_TYPE}.
* {@link HibernateOrmMapperOutboxPollingSettings#COORDINATION_ENTITY_MAPPING_AGENT_UUID_TYPE}.
* An exception ({@link org.hibernate.search.util.common.SearchException} will be thrown in case of such misconfiguration.
*/
public static final String AGENT_ENTITY_MAPPING = PREFIX + Radicals.AGENT_ENTITY_MAPPING;
Expand Down
Loading

0 comments on commit a8ac419

Please sign in to comment.