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

Examples of org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMPFieldBridge2


/*      */       }
/*      */     }
/*      */
/*      */     private Object loadField(int i)
/*      */     {
/* 1742 */       JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2)EntityTable.this.entity.getFields().get(i);
/*      */
/* 1744 */       StringBuffer query = new StringBuffer();
/* 1745 */       query.append("select ").append(field.getColumnName()).append(" from ").append(EntityTable.this.tableName).append(" where ");
/*      */
/* 1751 */       JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])(JDBCCMPFieldBridge2[])EntityTable.this.entity.getPrimaryKeyFields();
/* 1752 */       for (int pkI = 0; pkI < pkFields.length; pkI++)
/*      */       {
/* 1754 */         if (pkI > 0)
/*      */         {
/* 1756 */           query.append(" and ");
/*      */         }
/* 1758 */         query.append(pkFields[pkI].getColumnName()).append("=?");
/*      */       }
/*      */
/* 1761 */       if (EntityTable.this.log.isDebugEnabled())
/*      */       {
/* 1763 */         EntityTable.this.log.debug("executing: " + query.toString());
/*      */       }
/*      */
/* 1766 */       Object value = null;
/* 1767 */       Connection con = null;
/* 1768 */       PreparedStatement ps = null;
/* 1769 */       ResultSet rs = null;
/*      */       try
/*      */       {
/* 1773 */         con = EntityTable.this.dataSource.getConnection();
/* 1774 */         ps = con.prepareStatement(query.toString());
/*      */
/* 1776 */         for (int pkI = 0; pkI < pkFields.length; pkI++)
/*      */         {
/* 1778 */           JDBCCMPFieldBridge2 pkField = pkFields[pkI];
/* 1779 */           Object fieldValue = this.fields[pkField.getRowIndex()];
/* 1780 */           pkField.setArgumentParameters(ps, pkI + 1, fieldValue);
/*      */         }
/*      */
/* 1783 */         rs = ps.executeQuery();
/*      */
/* 1785 */         if (!rs.next())
View Full Code Here


      org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage msg = ((CMRInvocation)mi).getCmrMessage();

      // We are going to work with the context a lot
      EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext();
      JDBCCMRFieldBridge2 cmrField = (JDBCCMRFieldBridge2)mi.getArguments()[0];

      if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.ADD_RELATION == msg)
      {
         Object relatedId = mi.getArguments()[1];
         if(log.isTraceEnabled())
         {
            log.trace("Add relation: field=" + cmrField.getFieldName() +
               " id=" + ctx.getId() +
               " relatedId=" + relatedId);
         }

         cmrField.addRelatedId(ctx, relatedId);
      }
      else if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.REMOVE_RELATION == msg)
      {
         // call removeRelation
         Object relatedId = mi.getArguments()[1];
         if(log.isTraceEnabled())
         {
            log.trace("Remove relation: field=" + cmrField.getFieldName() +
               " id=" + ctx.getId() +
               " relatedId=" + relatedId);
         }

         cmrField.removeRelatedId(ctx, relatedId);
      }
      else
      {
         // this should not be possible we are using a type safe enum
         throw new EJBException("Unknown cmp2.0-relationship-message=" + msg);
View Full Code Here

      typeFactory = new JDBCTypeFactory(metaData.getTypeMapping(),
         metaData.getJDBCApplication().getValueClasses(),
         metaData.getJDBCApplication().getUserTypeMappings()
      );

      entityBridge = new JDBCEntityBridge2(this, metaData);
      entityBridge.init();

      Catalog catalog = getCatalog();
      catalog.addEntity(entityBridge);
View Full Code Here

      typeFactory = new JDBCTypeFactory(metaData.getTypeMapping(),
         metaData.getJDBCApplication().getValueClasses(),
         metaData.getJDBCApplication().getUserTypeMappings()
      );

      entityBridge = new JDBCEntityBridge2(this, metaData);
      entityBridge.init();

      Catalog catalog = getCatalog();
      catalog.addEntity(entityBridge);
View Full Code Here

   {
      String entityName = metadata.getEJBName();
      if(entityName != null)
      {
         Catalog catalog = entity.getManager().getCatalog();
         JDBCEntityBridge2 otherEntity = (JDBCEntityBridge2) catalog.getEntityByEJBName(entityName);
         if(otherEntity == null)
         {
            throw new DeploymentException("Unknown entity: " + entityName);
         }
         this.entity = otherEntity;
View Full Code Here

      }

      public void load(EntityEnterpriseContext ctx, FieldState state)
      {
         Object value;
         EntityTable relatedTable = relatedEntity.getTable();

         Connection con = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
         try
         {
            if(log.isDebugEnabled())
            {
               log.debug("executing: " + loadSql);
            }

            con = relatedTable.getDataSource().getConnection();
            ps = con.prepareStatement(loadSql);

            JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields();

            Object myPk = ctx.getId();
            int paramInd = 1;
            for(int i = 0; i < pkFields.length; ++i)
            {
               JDBCCMPFieldBridge2 pkField = pkFields[i];
               Object fieldValue = pkField.getPrimaryKeyValue(myPk);

               JDBCCMPFieldBridge2 relatedFkField = tableKeyFields[i];
               relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue);
            }

            rs = ps.executeQuery();

            while(rs.next())
            {
               value = relatedTable.loadRow(rs, false);
               state.addLoadedPk(value);
            }
         }
         catch(SQLException e)
         {
View Full Code Here

      }

      public void load(EntityEnterpriseContext ctx, FieldState state)
      {
         Object value;
         EntityTable relatedTable = relatedEntity.getTable();

         Connection con = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
         try
         {
            if(log.isDebugEnabled())
            {
               log.debug("executing: " + loadSql);
            }

            con = relatedTable.getDataSource().getConnection();
            ps = con.prepareStatement(loadSql);

            JDBCCMPFieldBridge2[] relatedFkFields = relatedCMRField.foreignKeyFields;
            JDBCCMPFieldBridge2[] myPkFields = relatedCMRField.relatedPKFields;

            Object myPk = ctx.getId();
            int paramInd = 1;
            for(int i = 0; i < relatedFkFields.length; ++i)
            {
               JDBCCMPFieldBridge2 myPkField = myPkFields[i];
               Object fieldValue = myPkField.getPrimaryKeyValue(myPk);

               JDBCCMPFieldBridge2 relatedFkField = relatedFkFields[i];
               relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue);
            }

            rs = ps.executeQuery();

            while(rs.next())
            {
               value = relatedTable.loadRow(rs, false);
               state.addLoadedPk(value);
            }
         }
         catch(SQLException e)
         {
View Full Code Here

   public Schema getSchema()
   {
      schema = (Schema)getApplicationData(SCHEMA);
      if(schema == null)
      {
         schema = new Schema(container.getEjbModule().getServiceName().getCanonicalName());
         putApplicationData(SCHEMA, schema);
      }
      return schema;
   }
View Full Code Here

   public Schema getSchema()
   {
      schema = (Schema)getApplicationData(SCHEMA);
      if(schema == null)
      {
         schema = new Schema();
         putApplicationData(SCHEMA, schema);
      }
      return schema;
   }
View Full Code Here

         if(metadata.getMethod().getName().startsWith("ejbSelect"))
         {
            try
            {
               QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod());
               Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema();
               EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand);
               selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge);
            }
            catch(FinderException e)
            {
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMPFieldBridge2

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.