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

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


      // drop relation tables
      JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields();
      for(int i = 0; i < cmrFields.length; ++i)
      {
         JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
         JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData();
         if(relationMetaData.isTableMappingStyle() && !relationMetaData.isTableDropped())
         {
            if(relationMetaData.getRemoveTable())
            {
               final boolean dropped = dropTable(relationMetaData.getDataSource(), cmrField.getQualifiedTableName());
               if(!dropped)
               {
                  success = false;
               }
               else
View Full Code Here


         JDBCFieldBridge field = (JDBCFieldBridge) path.getField();

         if(field instanceof JDBCAbstractCMRFieldBridge)
         {
            JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)field;
            final String alias;
            final JDBCFieldBridge[] keyFields;

            if(cmrField.hasForeignKey())
            {
               alias = aliasManager.getAlias(path.getPath(path.size() - 2));
               keyFields = cmrField.getForeignKeyFields();
            }
            else
            {
               alias = aliasManager.getAlias(path.getPath());
               if(cmrField.getMetaData().getRelationMetaData().isTableMappingStyle())
               {
                  keyFields = cmrField.getRelatedCMRField().getEntity().getPrimaryKeyFields();
               }
               else
               {
                  keyFields = cmrField.getRelatedCMRField().getForeignKeyFields();
               }
            }

            SQLUtil.getIsNullClause(node.not, keyFields, alias, sql);
         }
View Full Code Here

/*      */     }
/*      */
/*  247 */     JDBCAbstractCMRFieldBridge[] cmrFields = this.entity.getCMRFields();
/*  248 */     for (int i = 0; i < cmrFields.length; i++)
/*      */     {
/*  250 */       JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
/*  251 */       JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData();
/*      */
/*  254 */       EntityBridge relatedEntity = cmrField.getRelatedEntity();
/*  255 */       if ((!relationMetaData.isTableMappingStyle()) || (!createdTables.contains(relatedEntity.getEntityName())))
/*      */         continue;
/*  257 */       DataSource dataSource = relationMetaData.getDataSource();
/*      */
/*  259 */       boolean relTableExisted = SQLUtil.tableExists(cmrField.getQualifiedTableName(), this.entity.getDataSource());
/*      */
/*  261 */       if (relTableExisted)
/*      */       {
/*  263 */         if (relationMetaData.getAlterTable())
/*      */         {
/*  265 */           ArrayList oldNames = SQLUtil.getOldColumns(cmrField.getQualifiedTableName(), dataSource).getColumnNames();
/*  266 */           ArrayList newNames = new ArrayList();
/*  267 */           JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields();
/*  268 */           JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields();
/*  269 */           JDBCFieldBridge[] fields = new JDBCFieldBridge[leftKeys.length + rightKeys.length];
/*  270 */           System.arraycopy(leftKeys, 0, fields, 0, leftKeys.length);
/*  271 */           System.arraycopy(rightKeys, 0, fields, leftKeys.length, rightKeys.length);
/*      */
/*  274 */           boolean different = false;
/*  275 */           for (int j = 0; j < fields.length; j++)
/*      */           {
/*  277 */             JDBCFieldBridge field = fields[j];
/*      */
/*  279 */             String name = field.getJDBCType().getColumnNames()[0].toUpperCase();
/*  280 */             newNames.add(name);
/*      */
/*  282 */             if (oldNames.contains(name))
/*      */               continue;
/*  284 */             different = true;
/*  285 */             break;
/*      */           }
/*      */
/*  289 */           if (!different)
/*      */           {
/*  291 */             Iterator it = oldNames.iterator();
/*  292 */             while (it.hasNext())
/*      */             {
/*  294 */               String name = (String)(String)it.next();
/*  295 */               if (!newNames.contains(name))
/*      */               {
/*  297 */                 different = true;
/*  298 */                 break;
/*      */               }
/*      */             }
/*      */           }
/*      */
/*  303 */           if (different)
/*      */           {
/*  306 */             this.log.error("CMR table structure is incorrect for " + cmrField.getQualifiedTableName());
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */
/*  315 */       if ((!relationMetaData.isTableMappingStyle()) || (relationMetaData.isTableCreated()))
/*      */         continue;
/*  317 */       if (relationMetaData.getCreateTable())
/*      */       {
/*  319 */         createTable(dataSource, cmrField.getQualifiedTableName(), getRelationCreateTableSQL(cmrField, dataSource));
/*      */       }
/*      */       else
/*      */       {
/*  324 */         this.log.debug("Relation table not created as requested: " + cmrField.getQualifiedTableName());
/*      */       }
/*      */
/*  327 */       createCMRIndex(dataSource, cmrField);
/*      */
/*  329 */       if (!relationMetaData.getCreateTable())
/*      */         continue;
/*  331 */       issuePostCreateSQL(dataSource, relationMetaData.getDefaultTablePostCreateCmd(), cmrField.getQualifiedTableName());
/*      */     }
/*      */   }
View Full Code Here

/*  343 */     Set createdTables = getCreatedTables(this.manager);
/*      */
/*  345 */     JDBCAbstractCMRFieldBridge[] cmrFields = this.entity.getCMRFields();
/*  346 */     for (int i = 0; i < cmrFields.length; i++)
/*      */     {
/*  348 */       JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
/*  349 */       JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData();
/*      */
/*  352 */       EntityBridge relatedEntity = cmrField.getRelatedEntity();
/*      */
/*  357 */       if ((relationMetaData.isForeignKeyMappingStyle()) && (createdTables.contains(relatedEntity.getEntityName())))
/*      */       {
/*  359 */         createCMRIndex(((JDBCAbstractEntityBridge)relatedEntity).getDataSource(), cmrField);
/*      */       }
View Full Code Here

/*  870 */     JDBCAbstractCMRFieldBridge[] cmrFields = this.entity.getCMRFields();
/*  871 */     if (cmrFields != null)
/*      */     {
/*  873 */       for (int i = 0; i < cmrFields.length; i++)
/*      */       {
/*  875 */         JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
/*  876 */         if (!cmrField.getRelatedCMRField().getMetaData().isIndexed())
/*      */           continue;
/*  878 */         JDBCFieldBridge[] fkFields = cmrField.getForeignKeyFields();
/*  879 */         if (fkFields == null)
/*      */           continue;
/*  881 */         for (int fkInd = 0; fkInd < fkFields.length; fkInd++)
/*      */         {
/*  883 */           createCMPIndex(dataSource, fkFields[fkInd], indexNames);
View Full Code Here

/*      */
/*  651 */       JDBCFieldBridge field = (JDBCFieldBridge)path.getField();
/*      */
/*  653 */       if ((field instanceof JDBCAbstractCMRFieldBridge))
/*      */       {
/*  655 */         JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)field;
/*      */         JDBCFieldBridge[] keyFields;
/*      */         String alias;
/*      */         JDBCFieldBridge[] keyFields;
/*  659 */         if (cmrField.hasForeignKey())
/*      */         {
/*  661 */           String alias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/*  662 */           keyFields = cmrField.getForeignKeyFields();
/*      */         }
/*      */         else
/*      */         {
/*  666 */           alias = this.aliasManager.getAlias(path.getPath());
/*      */           JDBCFieldBridge[] keyFields;
/*  667 */           if (cmrField.getMetaData().getRelationMetaData().isTableMappingStyle())
/*      */           {
/*  669 */             keyFields = cmrField.getRelatedCMRField().getEntity().getPrimaryKeyFields();
/*      */           }
/*      */           else
/*      */           {
/*  673 */             keyFields = cmrField.getRelatedCMRField().getForeignKeyFields();
/*      */           }
/*      */         }
/*      */
/*  677 */         SQLUtil.getIsNullClause(node.not, keyFields, alias, sql);
/*      */       }
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

/*  846 */     for (int i = 1; i < path.size(); i++)
/*      */     {
/*  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 ");
/*      */
View Full Code Here

/* 1441 */         String curPath = path.getPath(i);
/* 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 ");
/*      */
View Full Code Here

/*  71 */     boolean success = true;
/*     */
/*  74 */     JDBCAbstractCMRFieldBridge[] cmrFields = this.entity.getCMRFields();
/*  75 */     for (int i = 0; i < cmrFields.length; i++)
/*     */     {
/*  77 */       JDBCAbstractCMRFieldBridge cmrField = cmrFields[i];
/*  78 */       JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData();
/*  79 */       if ((!relationMetaData.isTableMappingStyle()) || (relationMetaData.isTableDropped()))
/*     */         continue;
/*  81 */       if (!relationMetaData.getRemoveTable())
/*     */         continue;
/*  83 */       boolean dropped = dropTable(relationMetaData.getDataSource(), cmrField.getQualifiedTableName());
/*  84 */       if (!dropped)
/*     */       {
/*  86 */         success = false;
/*     */       }
/*     */       else
View Full Code Here

TOP

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

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.