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

Examples of org.jboss.ejb.plugins.cmp.jdbc2.schema.Schema


/* 1440 */         JDBCCMRFieldBridge2.this.foreignKeyFields[i].setValueInternal(ctx, null, JDBCCMRFieldBridge2.this.fkConstraint == null);
/*      */       }
/*      */
/* 1443 */       if (JDBCCMRFieldBridge2.this.fkConstraint != null)
/*      */       {
/* 1445 */         PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/* 1446 */         pctx.nullForeignKey(JDBCCMRFieldBridge2.this.fkConstraint);
/*      */       }
/*      */     }
View Full Code Here


/* 1457 */         JDBCCMRFieldBridge2.this.foreignKeyFields[i].setValueInternal(ctx, fieldValue, markDirty);
/*      */       }
/*      */
/* 1460 */       if (JDBCCMRFieldBridge2.this.fkConstraint != null)
/*      */       {
/* 1462 */         PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/* 1463 */         if (relatedId == null)
/*      */         {
/* 1465 */           pctx.nullForeignKey(JDBCCMRFieldBridge2.this.fkConstraint);
/*      */         }
/*      */         else
/*      */         {
/* 1469 */           pctx.nonNullForeignKey(JDBCCMRFieldBridge2.this.fkConstraint);
/*      */         }
/*      */       }
/*      */     }
View Full Code Here

/* 152 */     throw new EJBException("Internal error setting instance field " + getFieldName(), e);
/*     */   }
/*     */
/*     */   public void setValueInternal(EntityEnterpriseContext ctx, Object value, boolean makeDirty)
/*     */   {
/* 158 */     PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/*     */
/* 161 */     if ((this.cmpFieldIAmMappedTo != null) && (this.cmpFieldIAmMappedTo.isPrimaryKeyMember))
/*     */     {
/* 163 */       Object curValue = pctx.getFieldValue(this.rowIndex);
/* 164 */       if ((value != null) && (!value.equals(curValue)))
/*     */       {
/* 166 */         throw new IllegalStateException("Attempt to modify a primary key field through a foreign key field mapped to it: " + this.entity.getEntityName() + "." + this.cmpFieldIAmMappedTo.getFieldName() + " -> " + this.entity.getQualifiedTableName() + "." + this.cmpFieldIAmMappedTo.getColumnName() + ", current value=" + curValue + ", new value=" + value);
/*     */       }
/*     */
/* 181 */       makeDirty = false;
/*     */     }
/*     */     else
/*     */     {
/* 185 */       pctx.setFieldValue(this.rowIndex, value);
/*     */     }
/*     */
/* 188 */     if (makeDirty)
/*     */     {
/* 190 */       pctx.setDirty();
/*     */     }
/*     */   }
View Full Code Here

/* 399 */     return this.fieldName;
/*     */   }
/*     */
/*     */   public Object getValue(EntityEnterpriseContext ctx)
/*     */   {
/* 404 */     PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/* 405 */     return pctx.getFieldValue(this.rowIndex);
/*     */   }
View Full Code Here

/*     */   }
/*     */
/*     */   public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx)
/*     */     throws CreateException
/*     */   {
/*  75 */     PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
/*     */     Object pk;
/*  76 */     if (ctx.getId() == null) { Connection con = null;
/*  79 */       PreparedStatement ps = null;
/*  80 */       ResultSet rs = null;
/*     */       Object pk;
/*     */       try { if (this.log.isDebugEnabled())
/*     */         {
/*  85 */           this.log.debug("executing sql: " + this.pkSql);
/*     */         }
/*     */
/*  88 */         con = this.entityBridge.getDataSource().getConnection();
/*  89 */         ps = con.prepareStatement(this.pkSql);
/*  90 */         rs = ps.executeQuery();
/*     */
/*  92 */         if (!rs.next())
/*     */         {
/*  94 */           throw new CreateException("pk-sql " + this.pkSql + " returned no results!");
/*     */         }
/*     */
/*  97 */         pk = this.pkField.loadArgumentResults(rs, 1);
/*  98 */         pctx.setFieldValue(this.pkField.getRowIndex(), pk);
/*  99 */         pk = this.entityBridge.extractPrimaryKeyFromInstance(ctx);
/*     */       }
/*     */       catch (SQLException e)
/*     */       {
/* 103 */         this.log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e);
/* 104 */         throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState());
/*     */       }
/*     */       finally
/*     */       {
/* 109 */         JDBCUtil.safeClose(rs);
/* 110 */         JDBCUtil.safeClose(ps);
/* 111 */         JDBCUtil.safeClose(con);
/*     */       }
/*     */
/* 114 */       if (pk == null)
/*     */       {
/* 116 */         this.log.error("Primary key for created instance is null.");
/* 117 */         throw new CreateException("Primary key for created instance is null.");
/*     */       }
/*     */
/* 120 */       pctx.setPk(pk);
/*     */     }
/*     */     else
/*     */     {
/*     */       try
/*     */       {
/* 127 */         pctx.flush();
/*     */       }
/*     */       catch (SQLException e)
/*     */       {
/* 131 */         if ("23000".equals(e.getSQLState()))
/*     */         {
View Full Code Here

         {
            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)
            {
               throw new DeploymentException(e.getMessage());
View Full Code Here

/*     */       {
/*     */         try
/*     */         {
/* 165 */           QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod());
/* 166 */           Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema();
/* 167 */           EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand);
/* 168 */           selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge);
/*     */         }
/*     */         catch (FinderException e)
/*     */         {
/* 172 */           throw new DeploymentException(e.getMessage());
View Full Code Here

         created = row;
         row.state = CREATED;

         rowByPk.put(row.pk, row);

         JDBCCMPFieldBridge2 versionField = entity.getVersionField();
         if(versionField != null)
         {
            row.fields[versionField.getVersionIndex()] = row.fields[versionField.getRowIndex()];
         }
      }
View Full Code Here

         // but since tableIndex and rowIndex of a field are the same
         // this should work ok
         int rsOffset = 1;
         for(int i = 0; i < tableFields.length; ++i)
         {
            JDBCCMPFieldBridge2 field = tableFields[i];
            if(searchableOnly && !field.getJDBCType().isSearchable())
            {
               row.fields[field.getRowIndex()] = NOT_LOADED;
               --rsOffset;
               continue;
            }

            Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + rsOffset);
            row.fields[field.getRowIndex()] = columnValue;

            if(field.getVersionIndex() != -1)
            {
               row.fields[field.getVersionIndex()] = columnValue;
            }
         }

         Object[] relations = (relationsTotal > 0 ? new Object[relationsTotal] : null);
View Full Code Here

         Object pk = null;
         JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields();
         //int rsInd = 1;
         for(int i = 0; i < pkFields.length; ++i)
         {
            JDBCCMPFieldBridge2 field = pkFields[i];
            //Object columnValue = field.loadArgumentResults(rs, rsInd++);
            Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + 1);
            pk = field.setPrimaryKeyValue(pk, columnValue);
         }
         return pk;
      }
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc2.schema.Schema

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.