Package org.jboss.ejb.plugins.cmp.jdbc.bridge

Examples of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractEntityBridge


/*      */       {
/* 1049 */         addForeignKeyConstraint(metaData.getRelationMetaData().getDataSource(), cmrField.getQualifiedTableName(), cmrField.getFieldName(), cmrField.getTableKeyFields(), cmrField.getEntity().getQualifiedTableName(), cmrField.getEntity().getPrimaryKeyFields());
/*      */       }
/* 1057 */       else if (cmrField.hasForeignKey())
/*      */       {
/* 1059 */         JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge)cmrField.getRelatedEntity();
/* 1060 */         addForeignKeyConstraint(cmrField.getEntity().getDataSource(), cmrField.getEntity().getQualifiedTableName(), cmrField.getFieldName(), cmrField.getForeignKeyFields(), relatedEntity.getQualifiedTableName(), relatedEntity.getPrimaryKeyFields());
/*      */       }
/*      */
/*      */     }
/*      */     else
/*      */     {
View Full Code Here


/*  457 */         String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/*  458 */         SQLUtil.getColumnNamesClause(selectField, alias, sql);
/*      */       }
/*      */       else
/*      */       {
/*  462 */         JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge)path.getEntity();
/*  463 */         this.selectManager = selectEntity.getManager();
/*  464 */         this.selectObject = selectEntity;
/*  465 */         setTypeFactory(selectEntity.getManager().getJDBCTypeFactory());
/*      */
/*  467 */         String alias = this.aliasManager.getAlias(path.getPath());
/*  468 */         if (select.distinct)
/*      */         {
/*  470 */           SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql);
/*      */         }
/*      */         else
/*      */         {
/*  474 */           SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql);
/*      */         }
/*      */
/*  491 */         addLeftJoinPath(path);
/*      */       }
/*      */
/*      */     }
/*      */     else
/*      */     {
/*  497 */       ASTPath path = getPathFromChildren(child0);
/*      */
/*  499 */       if (path == null)
/*      */       {
/*  501 */         throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
/*      */       }
/*      */
/*  504 */       if (path.isCMPField())
/*      */       {
/*  506 */         JDBCFieldBridge selectField = path.getCMPField();
/*  507 */         this.selectManager = selectField.getManager();
/*  508 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*      */       }
/*  510 */       else if (path.isCMRField())
/*      */       {
/*  512 */         JDBCFieldBridge cmrField = (JDBCFieldBridge)path.getCMRField();
/*  513 */         this.selectManager = cmrField.getManager();
/*  514 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*  515 */         addLeftJoinPath(path);
/*      */       }
/*      */       else
/*      */       {
/*  519 */         JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge)path.getEntity();
/*  520 */         this.selectManager = entity.getManager();
/*  521 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/*  522 */         addLeftJoinPath(path);
/*      */       }
/*      */
/*  525 */       this.selectObject = child0;
View Full Code Here

/*      */
/*  716 */     addLeftJoinPath(path);
/*      */
/*  718 */     StringBuffer sql = (StringBuffer)data;
/*  719 */     JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)path.getCMRField();
/*  720 */     JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge)cmrField.getRelatedEntity();
/*  721 */     String alias = this.aliasManager.getAlias(path.getPath());
/*  722 */     SQLUtil.getIsNullClause(node.not, relatedEntity.getPrimaryKeyFields(), alias, sql);
/*      */
/*  724 */     return data;
/*      */   }
View Full Code Here

/*      */
/*      */   public Object visit(ASTMemberOf node, Object data)
/*      */   {
/*  729 */     Node member = node.jjtGetChild(0);
/*  730 */     ASTPath colPath = (ASTPath)node.jjtGetChild(1);
/*  731 */     JDBCAbstractEntityBridge colEntity = (JDBCAbstractEntityBridge)colPath.getEntity();
/*      */
/*  733 */     StringBuffer sql = (StringBuffer)data;
/*      */
/*  735 */     if (node.not)
/*      */     {
/*  737 */       sql.append(" NOT ");
/*      */     }
/*      */
/*  740 */     sql.append("EXISTS ").append('(').append("SELECT ");
/*      */
/*  742 */     if ((member instanceof ASTParameter))
/*      */     {
/*  744 */       ASTParameter toParam = (ASTParameter)member;
/*  745 */       verifyParameterEntityType(toParam.number, colEntity);
/*  746 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, colEntity));
/*      */
/*  748 */       String parentAlias = this.aliasManager.getAlias(colPath.getPath(0));
/*  749 */       String localParentAlias = this.aliasManager.getAlias(colPath.getPath(0) + "_local");
/*  750 */       JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge)colPath.getEntity(0);
/*  751 */       SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), localParentAlias, sql);
/*  752 */       sql.append(" FROM ").append(parentEntity.getQualifiedTableName()).append(' ').append(localParentAlias);
/*      */
/*  754 */       innerJoinPath(colPath, sql);
/*      */
/*  756 */       sql.append(" WHERE ");
/*      */
/*  758 */       JDBCAbstractEntityBridge col0 = (JDBCAbstractEntityBridge)colPath.getEntity(0);
/*  759 */       SQLUtil.getSelfCompareWhereClause(col0.getPrimaryKeyFields(), parentAlias, localParentAlias, sql);
/*  760 */       sql.append(" AND ");
/*      */
/*  762 */       String localColAlias = this.aliasManager.getAlias(colPath.getPath() + "_local");
/*  763 */       SQLUtil.getWhereClause(colEntity.getPrimaryKeyFields(), localColAlias, sql);
/*      */     }
/*      */     else
/*      */     {
/*  767 */       ASTPath memberPath = (ASTPath)member;
/*  768 */       JDBCAbstractEntityBridge memberEntity = (JDBCAbstractEntityBridge)memberPath.getEntity();
/*      */
/*  770 */       if (!memberEntity.equals(colEntity))
/*      */       {
/*  772 */         throw new IllegalStateException("Member must be if the same type as the collection, got: member=" + memberEntity.getEntityName() + ", collection=" + colEntity.getEntityName());
/*      */       }
/*      */
/*  778 */       String memberAlias = this.aliasManager.getAlias(memberPath.getPath());
/*      */
/*  780 */       if (memberPath.size() > 1)
/*      */       {
/*  782 */         String parentAlias = this.aliasManager.getAlias(memberPath.getPath(0) + "_local");
/*  783 */         JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge)memberPath.getEntity(0);
/*  784 */         SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql);
/*  785 */         sql.append(" FROM ").append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias);
/*      */
/*  787 */         innerJoinPath(memberPath, sql);
/*  788 */         innerJoinPath(colPath, sql);
/*      */       }
/*  790 */       else if (colPath.size() > 1)
/*      */       {
/*  792 */         String parentAlias = this.aliasManager.getAlias(colPath.getPath(0) + "_local");
/*  793 */         JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge)colPath.getEntity(0);
/*  794 */         SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql);
/*  795 */         sql.append(" FROM ").append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias);
/*      */
/*  797 */         innerJoinPath(colPath, sql);
/*      */       }
/*      */       else
/*      */       {
/*  801 */         throw new IllegalStateException("There should be collection valued path expression, not identification variable.");
/*      */       }
/*      */
/*  805 */       sql.append(" WHERE ");
/*      */
/*  807 */       JDBCAbstractEntityBridge member0 = (JDBCAbstractEntityBridge)memberPath.getEntity(0);
/*  808 */       String colAliasLocal = this.aliasManager.getAlias(colPath.getPath() + "_local");
/*  809 */       if (memberPath.size() > 1)
/*      */       {
/*  811 */         String memberAliasLocal = this.aliasManager.getAlias(memberPath.getPath() + "_local");
/*  812 */         SQLUtil.getSelfCompareWhereClause(colEntity.getPrimaryKeyFields(), memberAliasLocal, colAliasLocal, sql);
/*      */
/*  817 */         sql.append(" AND ");
/*      */
/*  819 */         String member0Alias = this.aliasManager.getAlias(memberPath.getPath(0));
/*  820 */         String member0AliasLocal = this.aliasManager.getAlias(memberPath.getPath(0) + "_local");
/*  821 */         SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), member0Alias, member0AliasLocal, sql);
/*      */       }
/*      */       else
/*      */       {
/*  828 */         SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), memberAlias, colAliasLocal, sql);
/*      */       }
/*      */     }
/*      */
/*  832 */     sql.append(')');
/*      */
View Full Code Here

/*      */     {
/*  848 */       String curPath = path.getPath(i);
/*  849 */       String joinAlias = this.aliasManager.getAlias(curPath + "_local");
/*      */
/*  851 */       JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)path.getCMRField(i);
/*  852 */       JDBCAbstractEntityBridge joinEntity = (JDBCAbstractEntityBridge)cmrField.getRelatedEntity();
/*      */
/*  854 */       JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();
/*      */
/*  856 */       String join = " INNER JOIN ";
/*      */
/*  858 */       if (relation.isTableMappingStyle())
/*      */       {
/*  860 */         String relTableAlias = this.aliasManager.getRelationTableAlias(curPath + "_local");
/*  861 */         sql.append(join).append(cmrField.getQualifiedTableName()).append(' ').append(relTableAlias).append(" ON ");
/*      */
/*  866 */         SQLUtil.getRelationTableJoinClause(cmrField, leftAlias, relTableAlias, sql);
/*      */
/*  868 */         sql.append(join).append(joinEntity.getQualifiedTableName()).append(' ').append(joinAlias).append(" ON ");
/*      */
/*  873 */         SQLUtil.getRelationTableJoinClause(cmrField.getRelatedCMRField(), joinAlias, relTableAlias, sql);
/*      */       }
/*      */       else
/*      */       {
/*  877 */         sql.append(join).append(joinEntity.getQualifiedTableName()).append(' ').append(joinAlias).append(" ON ");
/*      */
/*  883 */         SQLUtil.getJoinClause(cmrField, leftAlias, joinAlias, sql);
/*      */       }
/*      */
/*  886 */       leftAlias = joinAlias;
View Full Code Here

/*      */     {
/* 1202 */       args = new Object[] { node.distinct, node.jjtGetChild(0).jjtAccept(this, new StringBuffer()).toString() };
/*      */     }
/*      */     else
/*      */     {
/* 1206 */       JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge)cntPath.getEntity();
/* 1207 */       JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
/* 1208 */       if (pkFields.length > 1)
/*      */       {
/* 1210 */         this.countCompositePk = true;
/* 1211 */         this.forceDistinct = (node.distinct.length() > 0);
/*      */
/* 1213 */         addLeftJoinPath(cntPath);
/*      */
/* 1215 */         String alias = this.aliasManager.getAlias(cntPath.getPath());
/* 1216 */         SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), alias, buf);
/*      */
/* 1220 */         return buf;
/*      */       }
/*      */
/* 1224 */       String alias = this.aliasManager.getAlias(cntPath.getPath());
View Full Code Here

/*      */   }
/*      */
/*      */   public Object visit(ASTRangeVariableDeclaration node, Object data)
/*      */   {
/* 1364 */     ASTAbstractSchema schema = (ASTAbstractSchema)node.jjtGetChild(0);
/* 1365 */     JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge)schema.entity;
/* 1366 */     ASTIdentifier id = (ASTIdentifier)node.jjtGetChild(1);
/* 1367 */     declareTable(id.identifier, entity.getQualifiedTableName());
/* 1368 */     return data;
/*      */   }
View Full Code Here

/*      */     }
/*      */
/* 1381 */     ASTPath fromPath = (ASTPath)fromNode;
/* 1382 */     addLeftJoinPath(fromPath);
/* 1383 */     String fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/* 1384 */     JDBCAbstractEntityBridge fromEntity = (JDBCAbstractEntityBridge)fromPath.getEntity();
/*      */
/* 1386 */     if ((toNode instanceof ASTParameter))
/*      */     {
/* 1388 */       ASTParameter toParam = (ASTParameter)toNode;
/*      */
/* 1391 */       verifyParameterEntityType(toParam.number, fromEntity);
/*      */
/* 1393 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity));
/*      */
/* 1395 */       SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf);
/*      */     }
/*      */     else
/*      */     {
/* 1399 */       ASTPath toPath = (ASTPath)toNode;
/* 1400 */       addLeftJoinPath(toPath);
/* 1401 */       String toAlias = this.aliasManager.getAlias(toPath.getPath());
/* 1402 */       JDBCAbstractEntityBridge toEntity = (JDBCAbstractEntityBridge)toPath.getEntity();
/*      */
/* 1405 */       if (!fromEntity.equals(toEntity))
/*      */       {
/* 1407 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName());
/*      */       }
/*      */
/* 1415 */       SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf);
/*      */     }
/*      */
View Full Code Here

/* 1442 */         String joinAlias = this.aliasManager.getAlias(curPath);
/*      */
/* 1444 */         if (this.joinedAliases.add(joinAlias))
/*      */         {
/* 1446 */           JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)path.getCMRField(i);
/* 1447 */           JDBCAbstractEntityBridge joinEntity = (JDBCAbstractEntityBridge)cmrField.getRelatedEntity();
/*      */
/* 1449 */           JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();
/*      */
/* 1451 */           String join = path.innerJoin ? " INNER JOIN " : " LEFT OUTER JOIN ";
/*      */
/* 1453 */           if (relation.isTableMappingStyle())
/*      */           {
/* 1455 */             String relTableAlias = this.aliasManager.getRelationTableAlias(curPath);
/* 1456 */             sql.append(join).append(cmrField.getQualifiedTableName()).append(' ').append(relTableAlias).append(" ON ");
/*      */
/* 1461 */             SQLUtil.getRelationTableJoinClause(cmrField, leftAlias, relTableAlias, sql);
/*      */
/* 1463 */             sql.append(join).append(joinEntity.getQualifiedTableName()).append(' ').append(joinAlias).append(" ON ");
/*      */
/* 1468 */             SQLUtil.getRelationTableJoinClause(cmrField.getRelatedCMRField(), joinAlias, relTableAlias, sql);
/*      */           }
/*      */           else
/*      */           {
/* 1472 */             sql.append(join).append(joinEntity.getQualifiedTableName()).append(' ').append(joinAlias).append(" ON ");
/*      */
/* 1478 */             SQLUtil.getJoinClause(cmrField, leftAlias, joinAlias, sql);
/*      */           }
/*      */
/* 1481 */           join(joinAlias, sql);
View Full Code Here

/*     */   }
/*     */
/*     */   private static JDBCFieldBridge getCMPField(JDBCEntityPersistenceStore manager, Class intf, String fieldName)
/*     */   {
/* 355 */     Catalog catalog = manager.getCatalog();
/* 356 */     JDBCAbstractEntityBridge entityBridge = (JDBCAbstractEntityBridge)catalog.getEntityByInterface(intf);
/* 357 */     if (entityBridge == null)
/*     */     {
/* 359 */       throw new IllegalArgumentException("Entity not found in application catalog with interface=" + intf.getName());
/*     */     }
/*     */
/* 363 */     JDBCFieldBridge cmpField = (JDBCFieldBridge)entityBridge.getFieldByName(fieldName);
/* 364 */     if (cmpField == null)
/*     */     {
/* 366 */       throw new IllegalArgumentException("cmpField not found: cmpFieldName=" + fieldName + " entityName=" + entityBridge.getEntityName());
/*     */     }
/*     */
/* 370 */     return cmpField;
/*     */   }
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractEntityBridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.