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

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


      throws DeploymentException
   {

      super(manager, q);

      JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge();

      String finderName = q.getMethod().getName();

      // finder name will be like findByFieldName
      // we need to convert it to fieldName.
      String cmpFieldName = Character.toLowerCase(finderName.charAt(6)) + finderName.substring(7);

      // get the field
      cmpField = entity.getCMPFieldByName(cmpFieldName);
      if(cmpField == null)
      {
         throw new IllegalArgumentException(
            "No finder for this method: " + finderName);
      }

      // set the preload fields
      JDBCReadAheadMetaData readAhead = q.getReadAhead();
      if(readAhead.isOnFind())
      {
         setEagerLoadGroup(readAhead.getEagerLoadGroup());
      }

      // generate the sql
      StringBuffer sql = new StringBuffer(300);
      sql.append(SQLUtil.SELECT);

      SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), sql);
      if(getEagerLoadGroup() != null)
      {
         SQLUtil.appendColumnNamesClause(entity, getEagerLoadGroup(), sql);
      }
      sql.append(SQLUtil.FROM)
         .append(entity.getQualifiedTableName())
         .append(SQLUtil.WHERE);
      SQLUtil.getWhereClause(cmpField, sql);

      setSQL(sql.toString());
      setParameterList(QueryParameter.createParameters(0, cmpField));
View Full Code Here


   {
      super(manager, q);
      this.manager = manager;
      rowLocking = manager.getMetaData().hasRowLocking();

      JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge();

      JDBCTypeMappingMetaData typeMapping = this.manager.getJDBCTypeFactory().getTypeMapping();
      AliasManager aliasManager = new AliasManager(
         typeMapping.getAliasHeaderPrefix(),
         typeMapping.getAliasHeaderSuffix(),
         typeMapping.getAliasMaxLength()
      );

      String alias = aliasManager.getAlias(entity.getEntityName());

      StringBuffer select = new StringBuffer(200);
      SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), alias, select);

      StringBuffer from = new StringBuffer();
      from.append(entity.getQualifiedTableName())
         .append(' ')
         .append(alias);

      // set the preload fields
      JDBCReadAheadMetaData readAhead = q.getReadAhead();
      if(readAhead.isOnFind())
      {
         setEagerLoadGroup(readAhead.getEagerLoadGroup());
         if(getEagerLoadMask() != null)
         {
            SQLUtil.appendColumnNamesClause(entity.getTableFields(), getEagerLoadMask(), alias, select);

            List onFindCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes(
               entity, entity.getQualifiedTableName(), readAhead.getLeftJoins(), null);

            if(!onFindCMRList.isEmpty())
            {
               setOnFindCMRList(onFindCMRList);
               JDBCAbstractQueryCommand.leftJoinCMRNodes(alias, onFindCMRList, aliasManager, from);
               JDBCAbstractQueryCommand.appendLeftJoinCMRColumnNames(onFindCMRList, aliasManager, select);
            }
         }
      }

      StringBuffer where = new StringBuffer();
      SQLUtil.getWhereClause(entity.getPrimaryKeyFields(), alias, where);

      // generate the sql
      StringBuffer sql = new StringBuffer(300);
      if(rowLocking && readAhead.isOnFind() && getEagerLoadMask() != null)
      {
View Full Code Here

/*     */
/* 424 */     this.metaData = loadJDBCEntityMetaData();
/*     */
/* 427 */     this.typeFactory = new JDBCTypeFactory(this.metaData.getTypeMapping(), this.metaData.getJDBCApplication().getValueClasses(), this.metaData.getJDBCApplication().getUserTypeMappings());
/*     */
/* 434 */     this.entityBridge = new JDBCEntityBridge(this.metaData, this);
/* 435 */     this.entityBridge.init();
/*     */
/* 438 */     Catalog catalog = getCatalog();
/* 439 */     if (catalog == null)
/*     */     {
View Full Code Here

/*     */
/*  71 */     setSQL(compiler.getSQL());
/*     */
/*  74 */     if (compiler.isSelectEntity())
/*     */     {
/*  76 */       JDBCEntityBridge selectEntity = (JDBCEntityBridge)compiler.getSelectEntity();
/*     */
/*  79 */       setSelectEntity(selectEntity);
/*     */
/*  82 */       JDBCReadAheadMetaData readahead = metadata.getReadAhead();
/*  83 */       if (readahead.isOnFind())
/*     */       {
/*  85 */         setEagerLoadGroup(readahead.getEagerLoadGroup());
/*  86 */         setOnFindCMRList(compiler.getLeftJoinCMRList());
/*     */
/*  89 */         if (compiler.isSelectDistinct())
/*     */         {
/*  91 */           boolean[] mask = getEagerLoadMask();
/*  92 */           JDBCFieldBridge[] tableFields = selectEntity.getTableFields();
/*  93 */           for (int i = 0; i < tableFields.length; i++)
/*     */           {
/*  95 */             if ((mask[i] == 0) || (tableFields[i].getJDBCType().isSearchable()))
/*     */               continue;
/*  97 */             mask[i] = false;
View Full Code Here

/*      */     }
/*      */
/*  391 */     ASTPath fromPath = (ASTPath)fromNode;
/*  392 */     addJoinPath(fromPath);
/*  393 */     String fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/*  394 */     JDBCEntityBridge fromEntity = (JDBCEntityBridge)fromPath.getEntity();
/*      */
/*  396 */     if ((toNode instanceof ASTParameter))
/*      */     {
/*  398 */       ASTParameter toParam = (ASTParameter)toNode;
/*      */
/*  401 */       verifyParameterEntityType(toParam.number, fromEntity);
/*      */
/*  403 */       this.inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity));
/*      */
/*  405 */       SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf);
/*      */     }
/*      */     else
/*      */     {
/*  411 */       ASTPath toPath = (ASTPath)toNode;
/*  412 */       addJoinPath(toPath);
/*  413 */       String toAlias = this.aliasManager.getAlias(toPath.getPath());
/*  414 */       JDBCEntityBridge toEntity = (JDBCEntityBridge)toPath.getEntity();
/*      */
/*  417 */       if (!fromEntity.equals(toEntity))
/*      */       {
/*  419 */         throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName());
/*      */       }
/*      */
/*  425 */       SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf);
/*      */     }
/*      */
View Full Code Here

/*      */
/*  453 */       addJoinPath(path);
/*      */
/*  455 */       if (cmrField.getRelationMetaData().isForeignKeyMappingStyle())
/*      */       {
/*  457 */         JDBCEntityBridge childEntity = (JDBCEntityBridge)cmrField.getRelatedEntity();
/*  458 */         String childAlias = this.aliasManager.getAlias(path.getPath());
/*  459 */         SQLUtil.getIsNullClause(!not, childEntity.getPrimaryKeyFields(), childAlias, buf);
/*      */       }
/*      */       else
/*      */       {
/*  463 */         String relationTableAlias = this.aliasManager.getRelationTableAlias(path.getPath());
/*  464 */         SQLUtil.getIsNullClause(!not, cmrField.getTableKeyFields(), relationTableAlias, buf);
/*      */       }
/*  466 */       return;
/*      */     }
/*      */
/*  469 */     if (not)
/*      */     {
/*  471 */       buf.append(" NOT ");
/*      */     }
/*  473 */     buf.append("EXISTS ").append('(');
/*      */
/*  475 */     if (cmrField.getRelationMetaData().isForeignKeyMappingStyle())
/*      */     {
/*  477 */       JDBCEntityBridge childEntity = (JDBCEntityBridge)cmrField.getRelatedEntity();
/*  478 */       String childAlias = this.aliasManager.getAlias(path.getPath());
/*      */
/*  480 */       buf.append("SELECT ");
/*      */
/*  482 */       SQLUtil.getColumnNamesClause(childEntity.getPrimaryKeyFields(), childAlias, buf).append(" FROM ").append(childEntity.getQualifiedTableName()).append(' ').append(childAlias).append(" WHERE ");
/*      */
/*  486 */       SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf);
/*      */     }
/*      */     else
/*      */     {
View Full Code Here

/*      */     {
/*  773 */       return;
/*      */     }
/*      */
/*  776 */     JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField(i);
/*  777 */     JDBCEntityBridge entity = (JDBCEntityBridge)path.getEntity(i);
/*      */
/*  779 */     buf.append(", ").append(entity.getQualifiedTableName()).append(' ').append(this.aliasManager.getAlias(path.getPath(i)));
/*      */
/*  783 */     leftJoins(path.getPath(i), buf);
/*      */
/*  785 */     if (cmrField.getRelationMetaData().isTableMappingStyle())
/*      */     {
View Full Code Here

/*  809 */       JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)path.getCMRField();
/*  810 */       String parentAlias = this.aliasManager.getAlias(parentPath);
/*      */
/*  812 */       if (cmrField.getRelationMetaData().isForeignKeyMappingStyle())
/*      */       {
/*  814 */         JDBCEntityBridge childEntity = (JDBCEntityBridge)cmrField.getRelatedEntity();
/*  815 */         String childAlias = this.aliasManager.getAlias(path.getPath());
/*      */
/*  817 */         buf.append(" LEFT JOIN ").append(childEntity.getQualifiedTableName()).append(' ').append(childAlias).append(" ON ");
/*      */
/*  822 */         SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf);
/*      */       }
/*      */       else
/*      */       {
View Full Code Here

/*      */
/*  947 */     ASTPath path = (ASTPath)node.jjtGetChild(0);
/*      */
/*  950 */     this.declaredPaths.add(path.getPath());
/*      */
/*  953 */     JDBCEntityBridge entity = (JDBCEntityBridge)path.getEntity();
/*      */
/*  956 */     ASTIdentifier id = (ASTIdentifier)node.jjtGetChild(1);
/*      */
/*  959 */     String alias = this.aliasManager.getAlias(id.identifier);
/*      */
/*  962 */     addCollectionMemberJoinPath(alias, path);
/*      */
/*  965 */     this.aliasManager.addAlias(path.getPath(), alias);
/*      */
/*  967 */     buf.append(entity.getQualifiedTableName());
/*  968 */     buf.append(' ');
/*  969 */     buf.append(alias);
/*  970 */     leftJoins(path.getPath(), buf);
/*      */
/*  972 */     if ((this.onFindCMRJoin != null) && (alias.equals(this.selectAlias)))
View Full Code Here

/*      */   public Object visit(ASTRangeVariableDeclaration node, Object data)
/*      */   {
/*  994 */     StringBuffer buf = (StringBuffer)data;
/*      */
/*  996 */     ASTAbstractSchema schema = (ASTAbstractSchema)node.jjtGetChild(0);
/*  997 */     JDBCEntityBridge entity = (JDBCEntityBridge)schema.entity;
/*  998 */     ASTIdentifier id = (ASTIdentifier)node.jjtGetChild(1);
/*      */
/* 1000 */     String alias = this.aliasManager.getAlias(id.identifier);
/* 1001 */     buf.append(entity.getQualifiedTableName()).append(' ').append(alias);
/*      */
/* 1004 */     leftJoins(id.identifier, buf);
/*      */
/* 1006 */     if ((this.onFindCMRJoin != null) && (alias.equals(this.selectAlias)))
/*      */     {
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.