@Test public void testCollectionTypeWithTargetEntityAnnotation() { EntityClassMetadata<Data> metadata = factory .getEntityClassMetadata(Data.class); Class<?> type = metadata.getProperty("manyToMany").getType(); assertEquals(Set.class, type); }
public <T> EntityClassMetadata<T> getEntityClassMetadata( Class<T> mappedClass) throws IllegalArgumentException { assert mappedClass != null : "mappedClass must not be null"; if (mappedClass.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("The class is not an entity"); } PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); if (accessType == null) { throw new IllegalArgumentException( "The access type could not be determined"); } else { return (EntityClassMetadata<T>) getClassMetadata(mappedClass, accessType); } }
MetadataFactory { public <T> EntityClassMetadata<T> getEntityClassMetadata( Class<T> mappedClass) throws IllegalArgumentException { assert mappedClass != null : "mappedClass must not be null"; if (mappedClass.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("The class is not an entity"); } PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); if (accessType == null) { throw new IllegalArgumentException( "The access type could not be determined"); } else { return (EntityClassMetadata<T>) getClassMetadata(mappedClass, accessType); } } }
MetadataFactory { public <T> EntityClassMetadata<T> getEntityClassMetadata( Class<T> mappedClass) throws IllegalArgumentException { assert mappedClass != null : "mappedClass must not be null"; if (mappedClass.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("The class is not an entity"); } PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); if (accessType == null) { throw new IllegalArgumentException( "The access type could not be determined"); } else { return (EntityClassMetadata<T>) getClassMetadata(mappedClass, accessType); } } protected  MetadataFactory(); }
MetadataFactory { public <T> EntityClassMetadata<T> getEntityClassMetadata( Class<T> mappedClass) throws IllegalArgumentException { assert mappedClass != null : "mappedClass must not be null"; if (mappedClass.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("The class is not an entity"); } PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); if (accessType == null) { throw new IllegalArgumentException( "The access type could not be determined"); } else { return (EntityClassMetadata<T>) getClassMetadata(mappedClass, accessType); } } protected  MetadataFactory(); static MetadataFactory getInstance(); EntityClassMetadata<T> getEntityClassMetadata(
            Class<T> mappedClass); @SuppressWarnings("unchecked") ClassMetadata<T> getClassMetadata(Class<T> mappedClass,
            PersistentPropertyMetadata.AccessType accessType); }
MetadataFactory { public <T> EntityClassMetadata<T> getEntityClassMetadata( Class<T> mappedClass) throws IllegalArgumentException { assert mappedClass != null : "mappedClass must not be null"; if (mappedClass.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("The class is not an entity"); } PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); if (accessType == null) { throw new IllegalArgumentException( "The access type could not be determined"); } else { return (EntityClassMetadata<T>) getClassMetadata(mappedClass, accessType); } } protected  MetadataFactory(); static MetadataFactory getInstance(); EntityClassMetadata<T> getEntityClassMetadata(
            Class<T> mappedClass); @SuppressWarnings("unchecked") ClassMetadata<T> getClassMetadata(Class<T> mappedClass,
            PersistentPropertyMetadata.AccessType accessType);  }