javax.persistence.metamodel.IdentifiableType Java Examples

The following examples show how to use javax.persistence.metamodel.IdentifiableType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JpaMetadataProviderImpl.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
    * {@inheritDoc}
    */
@Override
protected synchronized void initializeMetadata(Collection<Class<?>> types) {
	LOG.info("Initializing JPA Metadata from " + entityManager);
	
	masterMetadataMap.clear();
	// QUESTION: When is JPA loaded so this service can initialize itself?
	// Build and store the map

	for ( IdentifiableType<?> identifiableType : entityManager.getMetamodel().getEntities() ) {
           //Only extract the metadata if EntityType and not a MappedSuperClass
           if(identifiableType instanceof EntityType<?>){
               EntityType<?> type = (EntityType<?>)identifiableType;
               try {
                   masterMetadataMap.put(type.getBindableJavaType(), getMetadataForClass(type.getBindableJavaType()));
                   if (LOG.isDebugEnabled()) {
                       LOG.debug("Added Metadata For: " + type.getBindableJavaType());
                   }
               } catch (Exception ex) {
                   LOG.error("Error obtaining JPA metadata for type: " + type.getJavaType(), ex);
               }
		}
	}
}
 
Example #2
Source File: Helper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static AttributeSource resolveAttributeSource(SessionFactoryImplementor sessionFactory, ManagedType managedType) {
	if ( EmbeddableTypeImpl.class.isInstance( managedType ) ) {
		return new ComponentAttributeSource( ( (EmbeddableTypeImpl) managedType ).getHibernateType() );
	}
	else if ( IdentifiableType.class.isInstance( managedType ) ) {
		final String entityName = managedType.getJavaType().getName();
		log.debugf( "Attempting to resolve managed type as entity using %s", entityName );
		return new EntityPersisterAttributeSource( sessionFactory.getEntityPersister( entityName ) );
	}
	else {
		throw new IllegalArgumentException(
				String.format( "Unknown ManagedType implementation [%s]", managedType.getClass() )
		);
	}
}
 
Example #3
Source File: SingularAttributePath.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ManagedType<X> resolveManagedType(SingularAttribute<?, X> attribute) {
	if ( Attribute.PersistentAttributeType.BASIC == attribute.getPersistentAttributeType() ) {
		return null;
	}
	else if ( Attribute.PersistentAttributeType.EMBEDDED == attribute.getPersistentAttributeType() ) {
		return (EmbeddableType<X>) attribute.getType();
	}
	else {
		return (IdentifiableType<X>) attribute.getType();
	}
}
 
Example #4
Source File: EntityGraphImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean appliesTo(EntityType<? super T> entityType) {
	if ( this.entityType.equals( entityType ) ) {
		return true;
	}

	IdentifiableType superType = entityType.getSupertype();
	while ( superType != null ) {
		if ( superType.equals( entityType ) ) {
			return true;
		}
		superType = superType.getSupertype();
	}

	return false;
}
 
Example #5
Source File: CustomSpecifications.java    From spring-boot-rest-api-helpers with MIT License 4 votes vote down vote up
public Attribute getIdAttribute(EntityManager em, Class<T> clazz) {
    Metamodel m = em.getMetamodel();
    IdentifiableType<T> of = (IdentifiableType<T>) m.managedType(clazz);
    return of.getId(of.getIdType().getJavaType());
}
 
Example #6
Source File: JPAEntityTypeMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public IdentifiableType<? super X> getSupertype() {
  return null;
}
 
Example #7
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public IdentifiableType<? super X> getSupertype() {
  return null;
}