public <T> ClassMapper<T> mapperFor(Class<T> aClass) {
   for (ClassMapper<?> current : mappers) {
     if (current.canMap(aClass)) {
       return (ClassMapper<T>) current;
     }
   }
   return null;
 }
示例#2
0
  /**
   * This method is used to override "hasIdentifierMapper" in EntityMetaModels of entities which
   * have composite id and class defined for it. It's workaround for bug as found in forum
   * https://forum.hibernate.org/viewtopic.php?t=978915&highlight=
   *
   * @param sessionFactory
   */
  public static void fixCompositeIDHandling(SessionFactory sessionFactory) {
    fixCompositeIdentifierInMetaModel(sessionFactory, RObjectDeltaOperation.class);

    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtDate.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtPolyString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, ROExtLong.class);

    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignmentExtension.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtDate.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtPolyString.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtReference.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RAExtLong.class);

    fixCompositeIdentifierInMetaModel(sessionFactory, RObjectReference.class);
    for (RReferenceOwner owner : RReferenceOwner.values()) {
      fixCompositeIdentifierInMetaModel(sessionFactory, owner.getClazz());
    }

    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignmentReference.class);
    for (RCReferenceOwner owner : RCReferenceOwner.values()) {
      fixCompositeIdentifierInMetaModel(sessionFactory, owner.getClazz());
    }

    fixCompositeIdentifierInMetaModel(sessionFactory, RAssignment.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RExclusion.class);
    fixCompositeIdentifierInMetaModel(sessionFactory, RTrigger.class);
    for (RObjectType type : ClassMapper.getKnownTypes()) {
      fixCompositeIdentifierInMetaModel(sessionFactory, type.getClazz());
    }
  }
 void addMapper(ClassMapper<?> mapper) {
   mapper.setContext(this);
   mappers.add(mapper);
 }