DLSearch { public boolean isEmbeddableField(Class clazz, String property) { if (clazz == null) return false; Field field = null; try { field = ReflectionHelper.getDeclaredField(clazz, property); } catch (NoSuchFieldException e) { } if (field != null && ( ReflectionHelper.findAnnotation(field, Embedded.class) != null || ReflectionHelper.findAnnotation(field, EmbeddedId.class) != null)) return true; Method method = ReflectionHelper.getFieldGetter(clazz, property); if (method != null && ( ReflectionHelper.findAnnotation(method, Embedded.class) != null || ReflectionHelper.findAnnotation(method, EmbeddedId.class) != null)) return true; if (field == null && method == null) throw new IllegalArgumentException("Class " + clazz + " does not contain property " + property); return false; } DLSearch( final int rowCount, final int firstRow );  DLSearch();  DLSearch( final List<DLSort> sorts );  DLSearch( final List<DLSort> sorts, final int rowCount, final int firstRow );  DLSearch( final List<DLSort> sorts, final int rowCount, final int firstRow, Class<T> persistentClass ); void clearFilterCriterions(); void addFilterCriterions( final List<Criterion> criterions ); void addFilterCriterion( final Criterion criterion ); void removeFilterCriterions( final Criterion criterion ); int getFirstRow(); void setFirstRow( final int firstRow ); int getRowCount(); void setRowCount( final int rowCount ); Iterator<DLSort> getSorts(); void setSorts( final List<DLSort> sorts ); void addSort( final DLSort sort ); void addSort( final String column ); void clearSorts(); Collection<Criterion> getCriterions(); CacheMode getCacheMode(); void setCacheMode(CacheMode cacheMode); String addAliases( final String fullPath ); String addAliases( final String fullPath, final JoinType joinType ); void addFetch( final String ... paths); void addFetches( final String ... fullPaths); String addAlias( final String path ); String addAlias( final String path, JoinType joinType ); void addAlias( final String path, final String alias ); Alias addAlias( final String path, final String alias, final JoinType joinType ); Alias getAlias(final String alias); Alias getAliasForPath(final String path); String getAliasForFullPath(final String fullPath); String[] parsePath( final String fullPath ); Set<Alias> getAliases(); void addProjection( final Projection projection ); Collection<Projection> getProjections(); boolean isEmbeddableField(Class clazz, String property); String addAliasesForProperty(String pathWithProperty); String addAliasesForProperty(String pathWithProperty, JoinType joinType); boolean isDistinct(); void setDistinct( final boolean distinct ); @Deprecated void addAlias( final String path, final String alias, final int joinType ); @Deprecated void addAlias( final String path, final int joinType ); @Override String toString();  }
@Test public void isEmbeddableField() throws Exception { DLSearch dlSearch = new DLSearch<Entity>(Collections.<DLSort>emptyList(), 10, 1, Entity.class); assertTrue("@Embedded on field resolved", dlSearch.isEmbeddableField(Entity.class, "embeddedEntity")); assertTrue("@Embedded on method resolved", dlSearch.isEmbeddableField(Entity.class, "embeddedEntityMethod")); assertFalse("@Embedded on field missing", dlSearch.isEmbeddableField(Entity.class, "manyToOneEntity")); assertTrue("@Embedded on inner field resolved", dlSearch.isEmbeddableField(ManyToOneEntity.class, "embeddedEntity")); assertTrue("@Embedded on inner method resolved", dlSearch.isEmbeddableField(ManyToOneEntity.class, "embeddedEntityMethod")); assertFalse("@Embedded on inner field missing", dlSearch.isEmbeddableField(ManyToOneEntity.class, "property")); }