private <K, V> MapJoinImplementor<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, JoinType jt) { if ( jt.equals( JoinType.RIGHT ) ) { throw new UnsupportedOperationException( "RIGHT JOIN not supported" ); } // TODO : runtime check that the attribute in fact belongs to this From's model/bindable final Class<V> attributeType = map.getBindableJavaType(); return new MapAttributeJoin<X, K, V>( criteriaBuilder(), attributeType, this, map, jt ); }
private <K, V> MapJoinImplementor<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, JoinType jt) { if ( jt.equals( JoinType.RIGHT ) ) { throw new UnsupportedOperationException( "RIGHT JOIN not supported" ); } // TODO : runtime check that the attribute in fact belongs to this From's model/bindable final Class<V> attributeType = map.getBindableJavaType(); return new MapAttributeJoin<X, K, V>( criteriaBuilder(), attributeType, this, map, jt ); }
/** * Gets name of the attribute type. For collection and map type attribute, the name is * appended with generic type argument names. * @param attr */ public static String getAttributeTypeName(Attribute<?, ?> attr) { StringBuilder name = new StringBuilder(attr.getJavaType().getSimpleName()); switch (attr.getPersistentAttributeType()) { case ONE_TO_MANY: case ELEMENT_COLLECTION: name.append("<") .append(((PluralAttribute<?,?,?>)attr).getBindableJavaType().getSimpleName()) .append(">"); break; case MANY_TO_MANY: name.append("<") .append(((MapAttribute<?,?,?>)attr).getKeyJavaType().getSimpleName()) .append(',') .append(((MapAttribute<?,?,?>)attr).getBindableJavaType().getSimpleName()) .append(">"); break; default: } return name.toString(); }
private <K, V> MapAttributeJoin<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, String alias, JoinType jt) { checkJoin(map, jt); final Class<V> attributeType = map.getBindableJavaType(); MapAttributeJoin<X, K, V> join = new MapAttributeJoin<X, K, V>(criteriaBuilder, attributeType, this, map, jt); join.setAlias(alias); return join; }
private <K, V> MapAttributeJoin<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, String alias, JoinType jt) { checkJoin(map, jt); final Class<V> attributeType = map.getBindableJavaType(); MapAttributeJoin<X, K, V> join = new MapAttributeJoin<X, K, V>(criteriaBuilder, attributeType, this, map, jt); join.setAlias(alias); return join; }
private void encodeManagedType(ManagedType<?> type, Element parent) { Document doc = parent.getOwnerDocument(); Element root = doc.createElement(type.getPersistenceType().toString().toLowerCase()); parent.appendChild(root); root.setAttribute(ATTR_NAME, type.getJavaType().getSimpleName()); List<Attribute<?,?>> attributes = MetamodelHelper.getAttributesInOrder(type); for (Attribute<?,?> a : attributes) { String tag = MetamodelHelper.getTagByAttributeType(a); Element child = doc.createElement(tag); root.appendChild(child); child.setAttribute(ATTR_TYPE, typeOf(a.getJavaType())); if (a instanceof PluralAttribute) { if (a instanceof MapAttribute) { child.setAttribute(ATTR_KEY_TYPE, typeOf(((MapAttribute)a).getKeyJavaType())); child.setAttribute(ATTR_VALUE_TYPE, typeOf(((MapAttribute)a).getBindableJavaType())); } else { child.setAttribute(ATTR_MEMBER_TYPE, typeOf(((PluralAttribute)a).getBindableJavaType())); } } child.setTextContent(a.getName()); } }
/** * Correlates a join to a Map-valued association or element collection in * the enclosing query to a join object of the subquery and returns the * subquery join object. * * @param parentMap * join target of the containing query * @return subquery join */ public <X, K, V> MapJoin<X, K, V> correlate(MapJoin<X, K, V> parentCollection){ this.correlatedJoins.add(parentCollection); return new MapJoinImpl(parentCollection.getParentPath(), metamodel.managedType(parentCollection.getModel().getBindableJavaType()), metamodel, parentCollection.getJavaType(), internalCorrelate((FromImpl) parentCollection), parentCollection.getModel(), parentCollection.getJoinType(), (FromImpl) parentCollection); }
public <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt) { org.eclipse.persistence.expressions.Expression node; Class clazz = map.getBindableJavaType(); MapJoin<X, K, V> join = null; if (jt.equals(JoinType.INNER)) { node = this.currentNode.anyOf(map.getName()); } else if (jt.equals(JoinType.RIGHT)) { throw new UnsupportedOperationException(ExceptionLocalization.buildMessage("RIGHT_JOIN_NOT_SUPPORTED")); } else { node = this.currentNode.anyOfAllowingNone(map.getName()); } if (map.getElementType().getPersistenceType().equals(PersistenceType.BASIC)) { join = new BasicMapJoinImpl(this, this.metamodel, clazz, node, (Bindable) map, jt); } else { join = new MapJoinImpl(this, metamodel.managedType(clazz), this.metamodel, clazz, node, (Bindable) map, jt); } this.joins.add(join); ((FromImpl)join).isJoin = true; return join; }