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

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


/* 1034 */         this.selectAlias = this.aliasManager.getAlias(path.getPath(path.size() - 2));
/* 1035 */         SQLUtil.getColumnNamesClause(selectField, this.selectAlias, buf);
/*      */       }
/*      */       else
/*      */       {
/* 1040 */         JDBCEntityBridge selectEntity = (JDBCEntityBridge)path.getEntity();
/* 1041 */         this.selectManager = ((JDBCStoreManager)selectEntity.getManager());
/* 1042 */         this.selectObject = selectEntity;
/* 1043 */         setTypeFactory(this.selectManager.getJDBCTypeFactory());
/* 1044 */         selectEntity(path, node.distinct, buf);
/*      */       }
/*      */
/*      */     }
/*      */     else
/*      */     {
/* 1050 */       ASTPath path = getPathFromChildren(child0);
/*      */
/* 1052 */       if (path == null)
/*      */       {
/* 1054 */         throw new IllegalStateException("The function in SELECT clause does not contain a path expression.");
/*      */       }
/*      */
/* 1057 */       if (path.isCMPField())
/*      */       {
/* 1059 */         JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge)path.getCMPField();
/* 1060 */         this.selectManager = ((JDBCStoreManager)selectField.getManager());
/*      */       }
/* 1062 */       else if (path.isCMRField())
/*      */       {
/* 1064 */         JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/* 1065 */         this.selectManager = ((JDBCStoreManager)cmrField.getEntity().getManager());
/* 1066 */         addJoinPath(path);
/*      */       }
/*      */       else
/*      */       {
/* 1070 */         JDBCEntityBridge entity = (JDBCEntityBridge)path.getEntity();
/* 1071 */         this.selectManager = ((JDBCStoreManager)entity.getManager());
/* 1072 */         addJoinPath(path);
/*      */       }
/*      */
/* 1075 */       setTypeFactory(this.selectManager.getJDBCTypeFactory());
/* 1076 */       this.selectObject = child0;
View Full Code Here


/*      */
/* 1180 */     ASTPath toPath = (ASTPath)node.jjtGetChild(1);
/*      */
/* 1182 */     JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge)toPath.getCMRField();
/*      */
/* 1184 */     JDBCEntityBridge toChildEntity = (JDBCEntityBridge)toPath.getEntity();
/*      */
/* 1186 */     String pathStr = toPath.getPath(toPath.size() - 2);
/* 1187 */     String toParentAlias = this.aliasManager.getAlias(pathStr);
/* 1188 */     String toChildAlias = this.aliasManager.getAlias(toPath.getPath());
/* 1189 */     String relationTableAlias = null;
/* 1190 */     if (toCMRField.getRelationMetaData().isTableMappingStyle())
/*      */     {
/* 1192 */       relationTableAlias = this.aliasManager.getRelationTableAlias(toPath.getPath());
/*      */     }
/*      */
/* 1196 */     String fromAlias = null;
/* 1197 */     int fromParamNumber = -1;
/* 1198 */     if ((node.jjtGetChild(0) instanceof ASTParameter))
/*      */     {
/* 1200 */       ASTParameter fromParam = (ASTParameter)node.jjtGetChild(0);
/*      */
/* 1203 */       verifyParameterEntityType(fromParam.number, toChildEntity);
/*      */
/* 1205 */       fromParamNumber = fromParam.number;
/*      */     }
/*      */     else
/*      */     {
/* 1209 */       ASTPath fromPath = (ASTPath)node.jjtGetChild(0);
/* 1210 */       addJoinPath(fromPath);
/*      */
/* 1212 */       JDBCEntityBridge fromEntity = (JDBCEntityBridge)fromPath.getEntity();
/* 1213 */       fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/*      */
/* 1216 */       if (!fromEntity.equals(toChildEntity))
/*      */       {
/* 1218 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toChildEntity.getEntityName());
/*      */       }
/*      */
/*      */     }
/*      */
/* 1226 */     addLeftJoinPath(pathStr, toPath);
View Full Code Here

/*      */     {
/* 1556 */       args = new Object[] { node.distinct, new NodeStringWrapper(cntPath) };
/*      */     }
/*      */     else
/*      */     {
/* 1560 */       JDBCEntityBridge entity = (JDBCEntityBridge)cntPath.getEntity();
/* 1561 */       JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
/* 1562 */       if (pkFields.length > 1)
/*      */       {
/* 1564 */         this.countCompositePk = true;
/* 1565 */         this.forceDistinct = (node.distinct.length() > 0);
/* 1566 */         selectEntity(cntPath, this.forceDistinct, buf);
View Full Code Here

/*      */     {
/* 1838 */       selected = true;
/*      */     }
/* 1840 */     else if ((this.selectObject instanceof JDBCEntityBridge))
/*      */     {
/* 1842 */       JDBCEntityBridge entity = (JDBCEntityBridge)this.selectObject;
/* 1843 */       JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
/* 1844 */       for (int pkInd = 0; pkInd < pkFields.length; pkInd++)
/*      */       {
/* 1846 */         if (pkFields[pkInd] != cmpField)
/*      */           continue;
/* 1848 */         selected = true;
View Full Code Here

/* 1863 */     return selected;
/*      */   }
/*      */
/*      */   private void selectEntity(ASTPath path, boolean distinct, StringBuffer buf)
/*      */   {
/* 1868 */     JDBCEntityBridge selectEntity = (JDBCEntityBridge)path.getEntity();
/*      */
/* 1870 */     StringBuffer columnNamesClause = new StringBuffer(200);
/* 1871 */     addJoinPath(path);
/* 1872 */     this.selectAlias = this.aliasManager.getAlias(path.getPath());
/*      */
/* 1876 */     SQLUtil.getColumnNamesClause(selectEntity.getPrimaryKeyFields(), this.selectAlias, columnNamesClause);
/*      */
/* 1878 */     if (this.readAhead.isOnFind())
/*      */     {
/* 1880 */       String eagerLoadGroupName = this.readAhead.getEagerLoadGroup();
/* 1881 */       boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName);
/* 1882 */       if (distinct)
/* 1883 */         SQLUtil.appendSearchableColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, this.selectAlias, columnNamesClause);
/*      */       else {
/* 1885 */         SQLUtil.appendColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, this.selectAlias, columnNamesClause);
/*      */       }
/*      */       try
/*      */       {
/* 1889 */         this.leftJoinCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes(selectEntity, path.getPath(), this.readAhead.getLeftJoins(), this.declaredPaths);
/*      */       }
View Full Code Here

/*     */     }
/*     */
/* 119 */     int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue());
/* 120 */     int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue());
/*     */
/* 122 */     JDBCEntityBridge selectEntity = null;
/* 123 */     JDBCCMPFieldBridge selectField = null;
/* 124 */     SelectFunction selectFunction = null;
/* 125 */     if (compiler.isSelectEntity())
/*     */     {
/* 127 */       selectEntity = (JDBCEntityBridge)compiler.getSelectEntity();
/*     */     }
/* 129 */     else if (compiler.isSelectField())
/*     */     {
/* 131 */       selectField = (JDBCCMPFieldBridge)compiler.getSelectField();
/*     */     }
/*     */     else
/*     */     {
/* 135 */       selectFunction = compiler.getSelectFunction();
/*     */     }
/*     */
/* 140 */     JDBCReadAheadMetaData readahead = this.metadata.getReadAhead();
/*     */     boolean[] mask;
/*     */     List leftJoinCMRList;
/* 141 */     if ((selectEntity != null) && (readahead.isOnFind()))
/*     */     {
/* 143 */       boolean[] mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup());
/* 144 */       boolean modifiedMask = false;
/* 145 */       List leftJoinCMRList = compiler.getLeftJoinCMRList();
/*     */
/* 148 */       if (compiler.isSelectDistinct())
/*     */       {
/* 150 */         JDBCFieldBridge[] tableFields = selectEntity.getTableFields();
/* 151 */         for (int i = 0; i < tableFields.length; i++)
/*     */         {
/* 153 */           if ((mask[i] == 0) || (tableFields[i].getJDBCType().isSearchable()))
/*     */             continue;
/* 155 */           if (!modifiedMask)
View Full Code Here

/*     */
/* 139 */       return null;
/*     */     }
/* 141 */     if (CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage)
/*     */     {
/* 143 */       JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity();
/* 144 */       entity.scheduleForCascadeDelete(ctx);
/* 145 */       return null;
/*     */     }
/* 147 */     if (CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage)
/*     */     {
/* 149 */       JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity();
/* 150 */       entity.scheduleForBatchCascadeDelete(ctx);
/* 151 */       return null;
/*     */     }
/*     */
/* 156 */     throw new EJBException("Unknown cmp2.0-relationship-message=" + relationshipMessage);
/*     */   }
View Full Code Here

/*     */   private String getSQL(JDBCCMRFieldBridge cmrField, boolean[] preloadMask, int keyCount) throws DeploymentException
/*     */   {
/* 243 */     JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField);
/* 244 */     JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField);
/* 245 */     String relationTable = getQualifiedRelationTable(cmrField);
/* 246 */     JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/* 247 */     String relatedTable = relatedEntity.getQualifiedTableName();
/*     */
/* 250 */     boolean join = ((preloadMask != null) || (cmrField.allFkFieldsMappedToPkFields())) && (relatedKeyFields != relatedEntity.getPrimaryKeyFields());
/*     */     String relatedTableAlias;
/*     */     String relationTableAlias;
/*     */     String relatedTableAlias;
/* 256 */     if (join)
/*     */     {
/* 258 */       String relationTableAlias = getRelationTable(cmrField);
/* 259 */       relatedTableAlias = relatedTable.equals(relationTable) ? getRelationTable(cmrField) + '_' + cmrField.getFieldName() : relatedEntity.getTableName();
/*     */     }
/*     */     else
/*     */     {
/* 265 */       relationTableAlias = "";
/* 266 */       relatedTableAlias = "";
View Full Code Here

/*     */   private static boolean[] getPreloadMask(JDBCCMRFieldBridge cmrField)
/*     */   {
/* 337 */     boolean[] preloadMask = null;
/* 338 */     if (cmrField.getReadAhead().isOnFind())
/*     */     {
/* 340 */       JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/* 341 */       String eagerLoadGroup = cmrField.getReadAhead().getEagerLoadGroup();
/* 342 */       preloadMask = relatedEntity.getLoadGroupMask(eagerLoadGroup);
/*     */     }
/* 344 */     return preloadMask;
/*     */   }
View Full Code Here

/*      */   {
/*  186 */     int count = offset;
/*  187 */     Connection con = null;
/*  188 */     PreparedStatement ps = null;
/*  189 */     ResultSet rs = null;
/*  190 */     JDBCEntityBridge entityBridge = (JDBCEntityBridge)selectManager.getEntityBridge();
/*  191 */     boolean throwRuntimeExceptions = entityBridge.getMetaData().getThrowRuntimeExceptions();
/*      */
/*  195 */     if (throwRuntimeExceptions)
/*      */     {
/*      */       try
/*      */       {
/*  199 */         con = entityBridge.getDataSource().getConnection();
/*      */       }
/*      */       catch (SQLException sqle)
/*      */       {
/*  203 */         EJBException ejbe = new EJBException("Could not get a connection; " + sqle);
/*  204 */         ejbe.initCause(sqle);
/*  205 */         throw ejbe;
/*      */       }
/*      */
/*      */     }
/*      */
/*      */     try
/*      */     {
/*  213 */       if (log.isDebugEnabled())
/*      */       {
/*  215 */         log.debug("Executing SQL: " + sql);
/*  216 */         if ((limit != 0) || (offset != 0))
/*      */         {
/*  218 */           log.debug("Query offset=" + offset + ", limit=" + limit);
/*      */         }
/*      */
/*      */       }
/*      */
/*  223 */       if (!throwRuntimeExceptions)
/*      */       {
/*  225 */         con = entityBridge.getDataSource().getConnection();
/*      */       }
/*  227 */       ps = con.prepareStatement(sql);
/*      */
/*  230 */       if (entityBridge.getFetchSize() > 0)
/*      */       {
/*  232 */         ps.setFetchSize(entityBridge.getFetchSize());
/*      */       }
/*      */
/*  236 */       for (int i = 0; i < parameters.size(); i++)
/*      */       {
/*  238 */         QueryParameter parameter = (QueryParameter)parameters.get(i);
View Full Code Here

TOP

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

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.