Class CosIdBeforeConvertCallback

java.lang.Object
me.ahoo.cosid.spring.data.jdbc.CosIdBeforeConvertCallback
All Implemented Interfaces:
org.springframework.data.mapping.callback.EntityCallback<Object>, org.springframework.data.relational.core.mapping.event.BeforeConvertCallback<Object>

public class CosIdBeforeConvertCallback extends Object implements org.springframework.data.relational.core.mapping.event.BeforeConvertCallback<Object>
Fills the ids of a Spring Data JDBC aggregate before it is converted for an insert: its CosId fields through the runtime's IdFiller, then its @Id property, when still unset, from the idGenerator (as 4.x did with the shared generator). The @Id goes through Spring Data's property accessor, so an immutable aggregate (a record, a wither) comes back as a new instance.

An unset id is null, a number <= 0 or an empty string; long, int and String ids are supported, other id types are left to the application.

  • Field Details

    • DEFAULT_ID_GENERATOR

      public static final String DEFAULT_ID_GENERATOR
      The generator of @Id properties by default.
      See Also:
  • Constructor Details

    • CosIdBeforeConvertCallback

      public CosIdBeforeConvertCallback(me.ahoo.cosid.runtime.CosIdRuntime runtime, org.springframework.data.relational.core.mapping.RelationalMappingContext mappingContext)
      A callback that fills @Id properties from the default generator.
      Parameters:
      runtime - the runtime
      mappingContext - the mapping context of the aggregates
    • CosIdBeforeConvertCallback

      public CosIdBeforeConvertCallback(me.ahoo.cosid.runtime.CosIdRuntime runtime, org.springframework.data.relational.core.mapping.RelationalMappingContext mappingContext, String idGenerator)
      A callback.
      Parameters:
      runtime - the runtime
      mappingContext - the mapping context of the aggregates
      idGenerator - the generator of @Id properties
  • Method Details

    • onBeforeConvert

      public Object onBeforeConvert(Object aggregate)
      Specified by:
      onBeforeConvert in interface org.springframework.data.relational.core.mapping.event.BeforeConvertCallback<Object>