Ejemplo n.º 1
0
        /** {@inheritDoc} */
        public Member resolveMember(AttributeContext attributeContext) {
          final IdentifiableType identifiableType =
              (IdentifiableType) attributeContext.getOwnerType();
          final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel(identifiableType);
          if (!entityMetamodel.getIdentifierProperty().isVirtual()) {
            throw new IllegalArgumentException("expecting IdClass mapping");
          }
          org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
          if (!EmbeddedComponentType.class.isInstance(type)) {
            throw new IllegalArgumentException("expecting IdClass mapping");
          }

          final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
          final String attributeName = attributeContext.getPropertyMapping().getName();
          return componentType
              .getComponentTuplizer()
              .getGetter(componentType.getPropertyIndex(attributeName))
              .getMember();
        }