@SuppressWarnings("unchecked") public IdMetadata(IdentifiableType<T> source) { this.type = source; this.attributes = (Set<SingularAttribute<? super T, ?>>) (source.hasSingleIdAttribute() ? Collections.singleton(source.getId(source.getIdType().getJavaType())) : source.getIdClassAttributes()); }
try idAttrib = ((IdentifiableType) managedType).getId(IDClassEntity.class); Assert.fail();
private SingularAttribute getEntityId(EntityManager em, Class clazz) { Metamodel meta = em.getMetamodel(); IdentifiableType identifiableType = (IdentifiableType) meta.managedType(clazz); return identifiableType.getId(identifiableType.getIdType().getJavaType()); }
/** * Return the ORM path from the given rule. * * @param root * The {@link Root} used to resolved the path. * @param path * The path value. Nested path is accepted. * @param <U> * The entity type referenced by the {@link Root} * @param <T> * The resolved entity type of the path value. * @return The resolved {@link Path} from the root. */ @SuppressWarnings("unchecked") protected <U, T> Path<T> getOrmPath(final Root<U> root, final String path) { PathImplementor<?> currentPath = (PathImplementor<?>) root; for (final String pathFragment : path.split(DELIMITERS)) { currentPath = getNextPath(pathFragment, (From<?, ?>) currentPath); } // Fail safe identifier access for non singular target path if (currentPath instanceof SingularAttributeJoin) { currentPath = getNextPath(((IdentifiableType<?>) currentPath.getModel()).getId(Object.class).getName(), (From<?, ?>) currentPath); } return (Path<T>) currentPath; }
@SuppressWarnings("unchecked") public IdMetadata(IdentifiableType<T> source) { this.type = source; this.attributes = (Set<SingularAttribute<? super T, ?>>) (source.hasSingleIdAttribute() ? Collections.singleton(source.getId(source.getIdType().getJavaType())) : source.getIdClassAttributes()); }
try idAttrib = ((IdentifiableType) managedType).getId(EmbeddableEntity.class); Assert.fail();
@SuppressWarnings("unchecked") public IdMetadata(IdentifiableType<T> source) { this.type = source; this.attributes = (Set<SingularAttribute<? super T, ?>>) (source.hasSingleIdAttribute() ? Collections .singleton(source.getId(source.getIdType().getJavaType())) : source.getIdClassAttributes()); }
public static Set<SingularAttribute<?, ?>> getIdAttributes(IdentifiableType<?> entityType) { try { if (entityType.hasSingleIdAttribute()) { return Collections.<SingularAttribute<?, ?>>singleton(entityType.getId(entityType.getIdType().getJavaType())); } else { if (entityType.getIdType() == null) { return Collections.<SingularAttribute<?, ?>>singleton(entityType.getId(primitiveIdClass)); try { identifiableType = identifiableType.getSupertype(); return Collections.<SingularAttribute<?, ?>>singleton(identifiableType.getId(identifiableType.getIdType().getJavaType())); } catch (NullPointerException e2) {
public static Set<SingularAttribute<?, ?>> getIdAttributes(IdentifiableType<?> entityType) { try { if (entityType.hasSingleIdAttribute()) { return Collections.<SingularAttribute<?, ?>>singleton(entityType.getId(entityType.getIdType().getJavaType())); } else { if (entityType.getIdType() == null) { return Collections.<SingularAttribute<?, ?>>singleton(entityType.getId(primitiveIdClass)); try { identifiableType = identifiableType.getSupertype(); return Collections.<SingularAttribute<?, ?>>singleton(identifiableType.getId(identifiableType.getIdType().getJavaType())); } catch (NullPointerException e2) {