public String getName() { return mappedProperty.getName(); }
predicatePath.add( new MappedPredicate(parentNs, predicate, first ? property.getName() : null)); first = false;
MappedPath existingPath = properties.get(property.getName());
/** * Create a new Query-by-example query * * @param session * @param entity */ @SuppressWarnings("unchecked") public ExampleQuery(Configuration configuration, Session session, T entity) { this.session = Assert.notNull(session, "session"); this.entityPath = (PathBuilder) pathBuilderFactory.create(entity.getClass()); this.conditions = new BooleanBuilder(); BeanMap beanMap = new BeanMap(entity); MappedClass mappedClass = configuration.getMappedClass(entity.getClass()); for (MappedPath mappedPath : mappedClass.getProperties()) { MappedProperty<?> property = mappedPath.getMappedProperty(); Object value = property.getValue(beanMap); if (value != null // date/time values are skipped && !DATE_TIME_TYPES.contains(value.getClass()) // collection values are skipped && !property.isCollection() // map values are skipped && !property.isMap() // blank nodes are skipped && !(value instanceof BID)) { Expression<Object> propertyPath = (Expression) entityPath.get(property.getName(), property.getType()); conditions.and(ExpressionUtils.eqConst(propertyPath, value)); } } }
@Test public void MappedClass() throws SecurityException, NoSuchFieldException { Field field = Project.class.getDeclaredField("infos"); assertNotNull(field); MappedClass mappedClass = configuration.getMappedClass(Project.class); boolean containsInfos = false; for (MappedProperty<?> property : mappedClass.getDynamicProperties()) { if (property.isDynamic() && property.getName().equals("infos")) { containsInfos = true; assertEquals(UID.class, property.getKeyType()); assertTrue(Set.class.isAssignableFrom(property.getDynamicCollectionType())); assertEquals(String.class, property.getDynamicCollectionComponentType()); } } assertTrue("Could not find property 'infos'", containsInfos); }