private static Getter getGetter(Property mappingProperty) {
    if (mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation()) {
      return null;
    }

    PropertyAccessor pa =
        PropertyAccessorFactory.getPropertyAccessor(mappingProperty, EntityMode.POJO);
    return pa.getGetter(
        mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName());
  }
  /**
   * Generates a VersionProperty representation for an entity mapping given its version mapping
   * Property.
   *
   * @param property The version mapping Property.
   * @param lazyAvailable Is property lazy loading currently available.
   * @return The appropriate VersionProperty definition.
   */
  public static VersionProperty buildVersionProperty(
      EntityPersister persister,
      SessionFactoryImplementor sessionFactory,
      int attributeNumber,
      Property property,
      boolean lazyAvailable) {
    String mappedUnsavedValue = ((KeyValue) property.getValue()).getNullValue();

    VersionValue unsavedValue =
        UnsavedValueFactory.getUnsavedVersionValue(
            mappedUnsavedValue,
            getGetter(property),
            (VersionType) property.getType(),
            getConstructor(property.getPersistentClass()));

    boolean lazy = lazyAvailable && property.isLazy();

    return new VersionProperty(
        persister,
        sessionFactory,
        attributeNumber,
        property.getName(),
        property.getValue().getType(),
        new BaselineAttributeInformation.Builder()
            .setLazy(lazy)
            .setInsertable(property.isInsertable())
            .setUpdateable(property.isUpdateable())
            .setValueGenerationStrategy(property.getValueGenerationStrategy())
            .setNullable(property.isOptional())
            .setDirtyCheckable(property.isUpdateable() && !lazy)
            .setVersionable(property.isOptimisticLocked())
            .setCascadeStyle(property.getCascadeStyle())
            .createInformation(),
        unsavedValue);
  }
  public static InDatabaseValueGenerationStrategyImpl create(
      SessionFactoryImplementor sessionFactoryImplementor,
      Property mappingProperty,
      ValueGeneration valueGeneration) {
    final int numberOfMappedColumns =
        mappingProperty.getType().getColumnSpan(sessionFactoryImplementor);
    if (numberOfMappedColumns == 1) {
      return new InDatabaseValueGenerationStrategyImpl(
          valueGeneration.getGenerationTiming(),
          valueGeneration.referenceColumnInSql(),
          new String[] {valueGeneration.getDatabaseGeneratedReferencedColumnValue()});

    } else {
      if (valueGeneration.getDatabaseGeneratedReferencedColumnValue() != null) {
        LOG.debugf(
            "Value generator specified column value in reference to multi-column attribute [%s -> %s]; ignoring",
            mappingProperty.getPersistentClass(), mappingProperty.getName());
      }
      return new InDatabaseValueGenerationStrategyImpl(
          valueGeneration.getGenerationTiming(),
          valueGeneration.referenceColumnInSql(),
          new String[numberOfMappedColumns]);
    }
  }