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

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


      {
         args = new Object[]{node.distinct, new NodeStringWrapper(cntPath)};
      }
      else
      {
         JDBCEntityBridge entity = (JDBCEntityBridge) cntPath.getEntity();
         final JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
         if(pkFields.length > 1)
         {
            countCompositePk = true;
            forceDistinct = node.distinct.length() > 0;
            selectEntity(cntPath, forceDistinct, buf);
View Full Code Here


      {
         selected = true;
      }
      else if(selectObject instanceof JDBCEntityBridge)
      {
         JDBCEntityBridge entity = (JDBCEntityBridge) selectObject;
         JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields();
         for(int pkInd = 0; pkInd < pkFields.length; ++pkInd)
         {
            if(pkFields[pkInd] == cmpField)
            {
               selected = true;
View Full Code Here

      return selected;
   }

   private void selectEntity(ASTPath path, boolean distinct, StringBuffer buf)
   {
      JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity();

      StringBuffer columnNamesClause = new StringBuffer(200);
      addJoinPath(path);
      selectAlias = aliasManager.getAlias(path.getPath());

      // get a list of all fields to be loaded
      // get the identifier for this field
      SQLUtil.getColumnNamesClause(selectEntity.getPrimaryKeyFields(), selectAlias, columnNamesClause);

      if(readAhead.isOnFind())
      {
         String eagerLoadGroupName = readAhead.getEagerLoadGroup();
         boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName);
         if(distinct)
            SQLUtil.appendSearchableColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause);
         else
            SQLUtil.appendColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause);

         try
         {
            leftJoinCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes(
               selectEntity, path.getPath(), readAhead.getLeftJoins(), declaredPaths);
View Full Code Here

      }

      int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue());
      int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue());

      JDBCEntityBridge selectEntity = null;
      JDBCCMPFieldBridge selectField = null;
      SelectFunction selectFunction = null;
      if(compiler.isSelectEntity())
      {
         selectEntity = (JDBCEntityBridge) compiler.getSelectEntity();
      }
      else if(compiler.isSelectField())
      {
         selectField = (JDBCCMPFieldBridge) compiler.getSelectField();
      }
      else
      {
         selectFunction = compiler.getSelectFunction();
      }

      boolean[] mask;
      List leftJoinCMRList;
      JDBCReadAheadMetaData readahead = metadata.getReadAhead();
      if(selectEntity != null && readahead.isOnFind())
      {
         mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup());
         boolean modifiedMask = false;
         leftJoinCMRList = compiler.getLeftJoinCMRList();

         // exclude non-searchable columns if distinct is used
         if(compiler.isSelectDistinct())
         {
            JDBCFieldBridge[] tableFields = selectEntity.getTableFields();
            for(int i = 0; i < tableFields.length; ++i)
            {
               if(mask[i] && !tableFields[i].getJDBCType().isSearchable())
               {
                  if(!modifiedMask)
View Full Code Here

         return null;
      }
      else if(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage)
      {
         JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity();
         entity.scheduleForCascadeDelete(ctx);
         return null;
      }
      else if(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage)
      {
         JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity();
         entity.scheduleForBatchCascadeDelete(ctx);
         return null;
      }
      else
      {
         // this should not be possible we are using a type safe enum
View Full Code Here

         metaData.getJDBCApplication().getValueClasses(),
         metaData.getJDBCApplication().getUserTypeMappings()
      );

      // create the bridge between java land and this engine (sql land)
      entityBridge = new JDBCEntityBridge(metaData, this);
      entityBridge.init();

      // add the entity bridge to the catalog
      Catalog catalog = getCatalog();
      if(catalog == null)
View Full Code Here

      setSQL(compiler.getSQL());

      // set select object
      if(compiler.isSelectEntity())
      {
         JDBCEntityBridge selectEntity = (JDBCEntityBridge) compiler.getSelectEntity();

         // set the select entity
         setSelectEntity(selectEntity);

         // set the preload fields
         JDBCReadAheadMetaData readahead = metadata.getReadAhead();
         if(readahead.isOnFind())
         {
            setEagerLoadGroup(readahead.getEagerLoadGroup());
            setOnFindCMRList(compiler.getLeftJoinCMRList());

            // exclude non-searchable columns if distinct is used
            if(compiler.isSelectDistinct())
            {
               boolean[] mask = getEagerLoadMask();
               JDBCFieldBridge[] tableFields = selectEntity.getTableFields();
               for(int i = 0; i < tableFields.length; ++i)
               {
                  if(mask[i] && !tableFields[i].getJDBCType().isSearchable())
                  {
                     mask[i] = false;
View Full Code Here

      Class localHomeClass = manager.getContainer().getLocalHomeClass();

      //
      // findByPrimaryKey
      //
      JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge();
      if(homeClass != null)
      {
         try
         {
            // try to get the finder method on the home interface
            Method method = homeClass.getMethod(FIND_BY_PK, new Class[]{entity.getPrimaryKeyClass()});

            JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method);
            JDBCReadAheadMetaData readAhead = (findByPKMD == null ?
               entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead());

            // got it add it to known finders
            JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                  method,
                  readAhead,
               entity.getMetaData().getQLCompiler(),
               false
            );
            knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));

            if(log.isDebugEnabled())
               log.debug("Added findByPrimaryKey query command for home interface");
         } catch(NoSuchMethodException e)
         {
            throw new DeploymentException("Home interface does not have a findByPrimaryKey method");
         }
      }

      if(localHomeClass != null)
      {

         Method method;
         try
         {
            // try to get the finder method on the local home interface
            method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() });
         } catch(NoSuchMethodException e)
         {
            throw new DeploymentException("Local home interface does " +
                  "not have the method findByPrimaryKey(" +
                  entity.getPrimaryKeyClass().getName() + ")");
         }

         // got it add it to known finders
         JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method);
         JDBCReadAheadMetaData readAhead = (findByPKMD == null ?
            entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead());
         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
         knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));

         if(log.isDebugEnabled())
            log.debug("Added findByPrimaryKey query command for local home interface");
      }
View Full Code Here

         Method[] homeMethods,
         Logger log) throws DeploymentException
   {

      JDBCCommandFactory factory = manager.getCommandFactory();
      JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge();
      for (int i = 0; i < homeMethods.length; i++)
      {
         Method method = homeMethods[i];

         if(!knownQueries.containsKey(method))
         {
            String name = method.getName();
            if(name.equals(FIND_ALL))
            {
               JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                     method,
                     entity.getMetaData().getReadAhead(),
                  entity.getMetaData().getQLCompiler(), false
                  );
               knownQueries.put(method, factory.createFindAllQuery(q));
            }
            else if(name.startsWith(FIND_BY) && !name.equals(FIND_BY_PK))
            {
               try
               {
                  JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                        method,
                        entity.getMetaData().getReadAhead(),
                     entity.getMetaData().getQLCompiler(), false);
                  knownQueries.put(method, factory.createFindByQuery(q));
               } catch (IllegalArgumentException e)
               {
                  log.debug("Could not create the finder " + name +
                        ", because no matching CMP field was found.");
View Full Code Here

   private String getSQL(JDBCCMRFieldBridge cmrField, boolean[] preloadMask, int keyCount) throws DeploymentException
   {
      JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField);
      JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField);
      String relationTable = getQualifiedRelationTable(cmrField);
      JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
      String relatedTable = relatedEntity.getQualifiedTableName();

      // do we need to join the relation table and the related table
      boolean join = ((preloadMask != null) || cmrField.allFkFieldsMappedToPkFields())
         && (relatedKeyFields != relatedEntity.getPrimaryKeyFields());

      // aliases for the tables, only required if we are joining the tables
      String relationTableAlias;
      String relatedTableAlias;
      if(join)
      {
         relationTableAlias = getRelationTable(cmrField);
         relatedTableAlias = (
            relatedTable.equals(relationTable) ? getRelationTable(cmrField) + '_' + cmrField.getFieldName() : relatedEntity.getTableName()
         );
      }
      else
      {
         relationTableAlias = "";
View Full Code Here

TOP

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

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.