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

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


/*  446 */         if (cmrField == null)
/*      */         {
/*  448 */           throw new DeploymentException("cmr-field in left-join was not found: cmr-field=" + leftJoin.getCmrField() + ", entity=" + entity.getEntityName());
/*      */         }
/*      */
/*  453 */         JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/*  454 */         String childPath = path + '.' + cmrField.getFieldName();
/*  455 */         if (declaredPaths != null)
/*      */         {
/*  457 */           declaredPaths.add(childPath);
/*      */         }
/*      */
/*  460 */         List subNodes = getLeftJoinCMRNodes(relatedEntity, childPath, leftJoin.getLeftJoins(), declaredPaths);
/*      */
/*  462 */         boolean[] mask = relatedEntity.getLoadGroupMask(leftJoin.getEagerLoadGroup());
/*  463 */         LeftJoinCMRNode node = new LeftJoinCMRNode(childPath, cmrField, mask, subNodes);
/*  464 */         leftJoinCMRNodes.add(node);
/*      */       }
/*      */
/*      */     }
View Full Code Here


/*      */   {
/*  480 */     for (int i = 0; i < onFindCMRNodes.size(); i++)
/*      */     {
/*  482 */       LeftJoinCMRNode node = (LeftJoinCMRNode)onFindCMRNodes.get(i);
/*  483 */       JDBCCMRFieldBridge cmrField = node.cmrField;
/*  484 */       JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/*  485 */       String relatedAlias = aliasManager.getAlias(node.path);
/*      */
/*  487 */       JDBCRelationMetaData relation = cmrField.getMetaData().getRelationMetaData();
/*  488 */       if (relation.isTableMappingStyle())
/*      */       {
/*  490 */         String relTableAlias = aliasManager.getRelationTableAlias(node.path);
/*  491 */         sb.append(" LEFT OUTER JOIN ").append(cmrField.getQualifiedTableName()).append(' ').append(relTableAlias).append(" ON ");
/*      */
/*  496 */         SQLUtil.getRelationTableJoinClause(cmrField, alias, relTableAlias, sb);
/*      */
/*  498 */         sb.append(" LEFT OUTER JOIN ").append(relatedEntity.getQualifiedTableName()).append(' ').append(relatedAlias).append(" ON ");
/*      */
/*  503 */         SQLUtil.getRelationTableJoinClause(cmrField.getRelatedCMRField(), relatedAlias, relTableAlias, sb);
/*      */       }
/*      */       else
/*      */       {
/*  508 */         sb.append(" LEFT OUTER JOIN ").append(relatedEntity.getQualifiedTableName()).append(' ').append(relatedAlias).append(" ON ");
/*      */
/*  513 */         SQLUtil.getJoinClause(cmrField, alias, relatedAlias, sb);
/*      */       }
/*      */
/*  519 */       List subNodes = node.onFindCMRNodes;
View Full Code Here

/*      */   {
/*  531 */     for (int i = 0; i < onFindCMRNodes.size(); i++)
/*      */     {
/*  533 */       LeftJoinCMRNode node = (LeftJoinCMRNode)onFindCMRNodes.get(i);
/*  534 */       JDBCCMRFieldBridge cmrField = node.cmrField;
/*  535 */       JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/*  536 */       String childAlias = aliasManager.getAlias(node.path);
/*      */
/*  539 */       SQLUtil.appendColumnNamesClause(relatedEntity.getPrimaryKeyFields(), childAlias, sb);
/*      */
/*  544 */       if (node.eagerLoadMask != null)
/*      */       {
/*  546 */         SQLUtil.appendColumnNamesClause(relatedEntity.getTableFields(), node.eagerLoadMask, childAlias, sb);
/*      */       }
/*      */
/*  552 */       List subNodes = node.onFindCMRNodes;
/*  553 */       if (subNodes.isEmpty())
/*      */         continue;
View Full Code Here

/*  563 */     for (int nodeInd = 0; nodeInd < onFindCMRNodes.size(); nodeInd++)
/*      */     {
/*  565 */       LeftJoinCMRNode node = (LeftJoinCMRNode)onFindCMRNodes.get(nodeInd);
/*  566 */       JDBCCMRFieldBridge cmrField = node.cmrField;
/*  567 */       ReadAheadCache myCache = cmrField.getJDBCStoreManager().getReadAheadCache();
/*  568 */       JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
/*  569 */       ReadAheadCache relatedCache = cmrField.getRelatedManager().getReadAheadCache();
/*      */
/*  572 */       ref[0] = null;
/*  573 */       index = relatedEntity.loadPrimaryKeyResults(rs, index, ref);
/*  574 */       Object relatedId = ref[0];
/*  575 */       boolean cacheRelatedData = relatedId != null;
/*      */
/*  577 */       if (pk != null)
/*      */       {
/*  579 */         if (cmrField.getMetaData().getRelatedRole().isMultiplicityOne())
/*      */         {
/*  582 */           myCache.addPreloadData(pk, cmrField, relatedId == null ? Collections.EMPTY_LIST : Collections.singletonList(relatedId));
/*      */         }
/*      */         else
/*      */         {
/*  588 */           Collection cachedValue = myCache.getCachedCMRValue(pk, cmrField);
/*  589 */           if (cachedValue == null)
/*      */           {
/*  591 */             cachedValue = new ArrayList();
/*  592 */             myCache.addPreloadData(pk, cmrField, cachedValue);
/*      */           }
/*      */
/*  595 */           if (relatedId != null)
/*      */           {
/*  597 */             if (cachedValue.contains(relatedId))
/*      */             {
/*  599 */               cacheRelatedData = false;
/*      */             }
/*      */             else
/*      */             {
/*  603 */               cachedValue.add(relatedId);
/*      */             }
/*      */           }
/*      */         }
/*      */
/*      */       }
/*      */
/*  610 */       if (node.eagerLoadMask != null)
/*      */       {
/*  612 */         JDBCFieldBridge[] tableFields = relatedEntity.getTableFields();
/*  613 */         for (int fieldInd = 0; fieldInd < tableFields.length; fieldInd++)
/*      */         {
/*  615 */           if (node.eagerLoadMask[fieldInd] == 0)
/*      */             continue;
/*  617 */           JDBCFieldBridge field = tableFields[fieldInd];
/*  618 */           ref[0] = null;
/*  619 */           index = field.loadArgumentResults(rs, index, ref);
/*      */
/*  621 */           if (!cacheRelatedData)
/*      */             continue;
/*  623 */           if (log.isTraceEnabled())
/*      */           {
/*  625 */             log.trace("Caching " + relatedEntity.getEntityName() + '[' + relatedId + "]." + field.getFieldName() + "=" + ref[0]);
/*      */           }
/*      */
/*  632 */           relatedCache.addPreloadData(relatedId, field, ref[0]);
/*      */         }
/*      */
View Full Code Here

/* 143 */     JDBCCommandFactory factory = this.manager.getCommandFactory();
/*     */
/* 145 */     Class homeClass = this.manager.getContainer().getHomeClass();
/* 146 */     Class localHomeClass = this.manager.getContainer().getLocalHomeClass();
/*     */
/* 151 */     JDBCEntityBridge entity = (JDBCEntityBridge)this.manager.getEntityBridge();
/* 152 */     if (homeClass != null)
/*     */     {
/*     */       try
/*     */       {
/* 157 */         Method method = homeClass.getMethod("findByPrimaryKey", new Class[] { entity.getPrimaryKeyClass() });
/*     */
/* 159 */         JDBCQueryMetaData findByPKMD = this.manager.getMetaData().getQueryMetaDataForMethod(method);
/* 160 */         JDBCReadAheadMetaData readAhead = findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead();
/*     */
/* 164 */         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
/*     */
/* 170 */         this.knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));
/*     */
/* 172 */         if (log.isDebugEnabled())
/* 173 */           log.debug("Added findByPrimaryKey query command for home interface");
/*     */       }
/*     */       catch (NoSuchMethodException e) {
/* 176 */         throw new DeploymentException("Home interface does not have a findByPrimaryKey method");
/*     */       }
/*     */     }
/*     */
/* 180 */     if (localHomeClass != null)
/*     */     {
/*     */       Method method;
/*     */       try
/*     */       {
/* 187 */         method = localHomeClass.getMethod("findByPrimaryKey", new Class[] { entity.getPrimaryKeyClass() });
/*     */       }
/*     */       catch (NoSuchMethodException e) {
/* 190 */         throw new DeploymentException("Local home interface does not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")");
/*     */       }
/*     */
/* 196 */       JDBCQueryMetaData findByPKMD = this.manager.getMetaData().getQueryMetaDataForMethod(method);
/* 197 */       JDBCReadAheadMetaData readAhead = findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead();
/*     */
/* 199 */       JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
/* 200 */       this.knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));
/*     */
/* 202 */       if (log.isDebugEnabled()) {
/* 203 */         log.debug("Added findByPrimaryKey query command for local home interface");
/*     */       }
View Full Code Here

/*     */
/*     */   private void addAutomaticFinders(JDBCStoreManager manager, Method[] homeMethods, Logger log)
/*     */     throws DeploymentException
/*     */   {
/* 316 */     JDBCCommandFactory factory = manager.getCommandFactory();
/* 317 */     JDBCEntityBridge entity = (JDBCEntityBridge)manager.getEntityBridge();
/* 318 */     for (int i = 0; i < homeMethods.length; i++)
/*     */     {
/* 320 */       Method method = homeMethods[i];
/*     */
/* 322 */       if (this.knownQueries.containsKey(method))
/*     */         continue;
/* 324 */       String name = method.getName();
/* 325 */       if (name.equals("findAll"))
/*     */       {
/* 327 */         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false);
/*     */
/* 332 */         this.knownQueries.put(method, factory.createFindAllQuery(q));
/*     */       } else {
/* 334 */         if ((!name.startsWith("findBy")) || (name.equals("findByPrimaryKey")))
/*     */           continue;
/*     */         try
/*     */         {
/* 338 */           JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false);
/*     */
/* 342 */           this.knownQueries.put(method, factory.createFindByQuery(q));
/*     */         }
/*     */         catch (IllegalArgumentException e) {
/* 345 */           log.debug("Could not create the finder " + name + ", because no matching CMP field was found.");
View Full Code Here

/*     */   {
/*  60 */     super(manager, q);
/*  61 */     this.manager = manager;
/*  62 */     this.rowLocking = manager.getMetaData().hasRowLocking();
/*     */
/*  64 */     JDBCEntityBridge entity = (JDBCEntityBridge)manager.getEntityBridge();
/*     */
/*  66 */     JDBCTypeMappingMetaData typeMapping = this.manager.getJDBCTypeFactory().getTypeMapping();
/*  67 */     AliasManager aliasManager = new AliasManager(typeMapping.getAliasHeaderPrefix(), typeMapping.getAliasHeaderSuffix(), typeMapping.getAliasMaxLength());
/*     */
/*  73 */     String alias = aliasManager.getAlias(entity.getEntityName());
/*     */
/*  75 */     StringBuffer select = new StringBuffer(200);
/*  76 */     SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), alias, select);
/*     */
/*  78 */     StringBuffer from = new StringBuffer();
/*  79 */     from.append(entity.getQualifiedTableName()).append(' ').append(alias);
/*     */
/*  84 */     JDBCReadAheadMetaData readAhead = q.getReadAhead();
/*  85 */     if (readAhead.isOnFind())
/*     */     {
/*  87 */       setEagerLoadGroup(readAhead.getEagerLoadGroup());
/*  88 */       if (getEagerLoadMask() != null)
/*     */       {
/*  90 */         SQLUtil.appendColumnNamesClause(entity.getTableFields(), getEagerLoadMask(), alias, select);
/*     */
/*  92 */         List onFindCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes(entity, entity.getQualifiedTableName(), readAhead.getLeftJoins(), null);
/*     */
/*  95 */         if (!onFindCMRList.isEmpty())
/*     */         {
/*  97 */           setOnFindCMRList(onFindCMRList);
/*  98 */           JDBCAbstractQueryCommand.leftJoinCMRNodes(alias, onFindCMRList, aliasManager, from);
/*  99 */           JDBCAbstractQueryCommand.appendLeftJoinCMRColumnNames(onFindCMRList, aliasManager, select);
/*     */         }
/*     */       }
/*     */     }
/*     */
/* 104 */     StringBuffer where = new StringBuffer();
/* 105 */     SQLUtil.getWhereClause(entity.getPrimaryKeyFields(), alias, where);
/*     */
/* 108 */     StringBuffer sql = new StringBuffer(300);
/* 109 */     if ((this.rowLocking) && (readAhead.isOnFind()) && (getEagerLoadMask() != null))
/*     */     {
/* 111 */       JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate();
View Full Code Here

/*    */   public JDBCFindAllQuery(JDBCStoreManager manager, JDBCQueryMetaData q)
/*    */     throws DeploymentException
/*    */   {
/* 45 */     super(manager, q);
/*    */
/* 47 */     JDBCEntityBridge entity = (JDBCEntityBridge)manager.getEntityBridge();
/*    */
/* 50 */     JDBCReadAheadMetaData readAhead = q.getReadAhead();
/* 51 */     if (readAhead.isOnFind())
/*    */     {
/* 53 */       setEagerLoadGroup(readAhead.getEagerLoadGroup());
/*    */     }
/*    */
/* 57 */     StringBuffer sql = new StringBuffer(300);
/* 58 */     sql.append("SELECT ");
/*    */
/* 60 */     SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), sql);
/* 61 */     if (getEagerLoadGroup() != null)
/*    */     {
/* 63 */       SQLUtil.appendColumnNamesClause(entity, getEagerLoadGroup(), sql);
/*    */     }
/* 65 */     sql.append(" FROM ").append(entity.getQualifiedTableName());
/*    */
/* 67 */     setSQL(sql.toString());
/*    */   }
View Full Code Here

/*  73 */     setLimitParam(compiler.getLimitParam());
/*  74 */     setLimitValue(compiler.getLimitValue());
/*     */
/*  77 */     if (compiler.isSelectEntity())
/*     */     {
/*  79 */       JDBCEntityBridge selectEntity = (JDBCEntityBridge)compiler.getSelectEntity();
/*     */
/*  82 */       setSelectEntity(selectEntity);
/*     */
/*  85 */       JDBCReadAheadMetaData readahead = metadata.getReadAhead();
/*  86 */       if (readahead.isOnFind())
/*     */       {
/*  88 */         setEagerLoadGroup(readahead.getEagerLoadGroup());
/*  89 */         setOnFindCMRList(compiler.getLeftJoinCMRList());
/*     */
/*  92 */         if (compiler.isSelectDistinct())
/*     */         {
/*  94 */           boolean[] mask = getEagerLoadMask();
/*  95 */           JDBCCMPFieldBridge[] tableFields = (JDBCCMPFieldBridge[])(JDBCCMPFieldBridge[])selectEntity.getTableFields();
/*  96 */           for (int i = 0; i < tableFields.length; i++)
/*     */           {
/*  98 */             if ((mask[i] == 0) || (tableFields[i].getJDBCType().isSearchable()))
/*     */               continue;
/* 100 */             mask[i] = false;
View Full Code Here

/*  61 */     this.metadata = ((JDBCDeclaredQueryMetaData)q);
/*     */
/*  64 */     initSelectObject(manager);
/*     */
/*  67 */     JDBCReadAheadMetaData readAhead = this.metadata.getReadAhead();
/*  68 */     JDBCEntityBridge selectEntity = getSelectEntity();
/*  69 */     if ((selectEntity != null) && (readAhead.isOnFind()))
/*     */     {
/*  71 */       setEagerLoadGroup(readAhead.getEagerLoadGroup());
/*     */     }
/*     */
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.