private void handleJoinTarget(JoinExpression je) { // type specifier if (je.getTarget() instanceof EntityPath<?>) { EntityPath<?> pe = (EntityPath<?>) je.getTarget(); if (pe.getMetadata().getParent() == null) { if (pe.getType().getPackage() != null){ String pn = pe.getType().getPackage().getName(); String typeName = pe.getType().getName().substring(pn.length() + 1); append(typeName); }else{ append(pe.getType().getName()); } append(" "); } } handle(je.getTarget()); }
public HibernateUpdateClause(SessionHolder session, EntityPath<?> entity, JPQLTemplates templates) { this.session = session; this.templates = templates; metadata.addJoin(JoinType.DEFAULT, entity.asExpr()); }
/** * @param newPath * @param path * @return */ private <P extends Path<?>> P addMetadataOf(P newPath, Path<?> path) { if (path.getMetadata().getParent() instanceof EntityPath) { EntityPath<?> parent = (EntityPath)path.getMetadata().getParent(); propertyMetadata.put(newPath, parent.getMetadata(path)); } return newPath; }
public MorphiaQuery(Morphia morphia, Datastore datastore, EntityCache cache, EntityPath<K> entityPath) { this(morphia, datastore, cache, entityPath.getType()); }
public static String getName(Path<?> path) { Path<?> parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { Object columnMetadata = ((EntityPath<?>) parent).getMetadata(path); if (columnMetadata instanceof ColumnMetadata) { return ((ColumnMetadata)columnMetadata).getName(); } } return path.getMetadata().getName(); }
@Override public long execute() { Query query = persistenceManager.newQuery(entity.getType()); if (metadata.getWhere() != null) { JDOQLSerializer serializer = new JDOQLSerializer(templates, entity);
/** * Create a new BeanGridDataSource instance with filter conditions * * @param sessionFactory * @param entity * root entity of the query * @param defaultOrder * default order for queries, if no order is specified * @param caseSensitive * case sensitive ordering * @param conditions * filter conditions */ @SuppressWarnings("unchecked") public BeanGridDataSource(SessionFactory sessionFactory, EntityPath<T> entity, OrderSpecifier<?> defaultOrder, boolean caseSensitive, @Nullable Predicate conditions) { this.sessionFactory = Assert.notNull(sessionFactory, "sessionFactory"); this.entityType = (Class<T>) Assert.notNull(entity.getType(), "entity has no type"); this.entityPath = new PathBuilder<T>(entity.getType(), entity.getMetadata()); this.defaultOrder = Assert.notNull(defaultOrder, "defaultOrder"); this.conditions = conditions; this.caseSensitive = caseSensitive; }
/** * Returns this path's column metadata if present. Otherwise returns default * metadata where the column name is equal to the path's name. */ public static ColumnMetadata getColumnMetadata(Path<?> path) { Path<?> parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { Object columnMetadata = ((EntityPath<?>) parent).getMetadata(path); if (columnMetadata instanceof ColumnMetadata) { return (ColumnMetadata)columnMetadata; } } return ColumnMetadata.named(path.getMetadata().getName()); }
public HibernateDeleteClause(SessionHolder session, EntityPath<?> entity, JPQLTemplates templates){ this.session = session; this.templates = templates; md.addJoin(JoinType.DEFAULT, entity.asExpr()); }
private void serializeVariables(List<JoinExpression> joins) { append(VARIABLES); for (int i = 1; i < joins.size(); i++) { final JoinExpression je = joins.get(i); if (i > 1) { append("; "); } // type specifier if (je.getTarget() instanceof EntityPath) { final EntityPath<?> pe = (EntityPath<?>) je.getTarget(); if (pe.getMetadata().getParent() == null) { append(pe.getType().getName()).append(" "); } } handle(je.getTarget()); } }
public JPAUpdateClause(EntityManager em, EntityPath<?> entity, JPQLTemplates templates){ this.entityManager = em; this.templates = templates; metadata.addJoin(JoinType.DEFAULT, entity.asExpr()); }
public static void orderBy(JPACommonQuery<?> query, EntityPath<?> entity, List<String> order) { PathBuilder<?> builder = new PathBuilder(entity.getType(), entity.getMetadata()); Map<String, PathBuilder<?>> joins = Maps.newHashMap(); for (String entry : order) { String[] tokens = DOT.split(entry); if (tokens.length > 1) { String[] parent = new String[tokens.length - 1]; System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); PathBuilder<?> parentAlias = join(query, builder, joins, StringUtils.join(parent, ".")); query.orderBy(parentAlias.getString(tokens[tokens.length - 1]).asc()); } else { query.orderBy(builder.getString(tokens[0]).asc()); } } }
public JPADeleteClause(EntityManager entityManager, EntityPath<?> entity, JPQLTemplates templates){ this.entityManager = entityManager; this.templates = templates; metadata.addJoin(JoinType.DEFAULT, entity.asExpr()); }