Examples of PersistentContext


Examples of org.jboss.as.cmp.jdbc2.PersistentContext

            loaded = true;
        }

        private Object getLoadedValue(CmpEntityBeanContext ctx) {
            if (!loaded) {
                PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
                pctx.loadCachedRelations(cmrIndex, this);
                if (!loaded) {
                    loader.load(ctx, this);
                    loaded = true;
                    cacheValue(ctx);
                }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

        public Object getCachedValue() {
            return value;
        }

        public void cacheValue(CmpEntityBeanContext ctx) {
            PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
            pctx.cacheRelations(cmrIndex, this);
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

            }
            return value;
        }

        private void loadOnlyFromCache(CmpEntityBeanContext ctx) {
            PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
            if (pctx == null) {
                throw new EJBException("Persistence context is not available! Make sure the CMR collection is accessed in the transaction it was obtained.");
            }
            pctx.loadCachedRelations(cmrIndex, this);
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

            for (int i = 0; i < foreignKeyFields.length; ++i) {
                foreignKeyFields[i].setValueInternal(ctx, null, fkConstraint == null);
            }

            if (fkConstraint != null) {
                PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
                pctx.nullForeignKey(fkConstraint);
            }
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

                Object fieldValue = relatedPKField.getPrimaryKeyValue(relatedId);
                foreignKeyFields[i].setValueInternal(ctx, fieldValue, markDirty);
            }

            if (fkConstraint != null) {
                PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
                if (relatedId == null) {
                    pctx.nullForeignKey(fkConstraint);
                } else {
                    pctx.nonNullForeignKey(fkConstraint);
                }
            }
        }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

        Object instance = ctx.getComponent().getCache().get(ctx.getPrimaryKey());
        // TODO: jeb - Set context on proxy
    }

    public void initInstance(CmpEntityBeanContext ctx) {
        ctx.setPersistenceContext(new PersistentContext(this, table.getRow(ctx.getPrimaryKey())));
        for (int i = 0; i < tableFields.length; ++i) {
            tableFields[i].initInstance(ctx);
        }

        for (int i = 0; i < cmrFields.length; ++i) {
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

        return fields;
    }

    public boolean isStoreRequired(CmpEntityBeanContext instance) {
        PersistentContext pctx = (PersistentContext) instance.getPersistenceContext();
        return pctx.isDirty();
    }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

        PersistentContext pctx = (PersistentContext) instance.getPersistenceContext();
        return pctx.isDirty();
    }

    public boolean isModified(CmpEntityBeanContext instance) {
        PersistentContext pctx = (PersistentContext) instance.getPersistenceContext();
        boolean modified = pctx.isDirty();

        if (!modified && cmrFields != null) {
            for (int i = 0; i < cmrFields.length; ++i) {
                final JDBCCMRFieldBridge2.FieldState cmrState = pctx.getCMRState(i);
                if (cmrState != null && cmrState.isModified()) {
                    modified = true;
                    break;
                }
            }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

            throw new EJBException("Internal error setting instance field " + getFieldName(), e);
        }
    }

    public void setValueInternal(CmpEntityBeanContext ctx, Object value, boolean makeDirty) {
        PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();

        // todo this is weird
        if (cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember) {
            Object curValue = pctx.getFieldValue(rowIndex);
            if (value != null && !value.equals(curValue)) {
                throw new IllegalStateException(
                        "Attempt to modify a primary key field through a foreign key field mapped to it: "
                                +
                                entity.getEntityName()
                                + "."
                                + cmpFieldIAmMappedTo.getFieldName()
                                +
                                " -> "
                                + entity.getQualifiedTableName()
                                + "."
                                + cmpFieldIAmMappedTo.getColumnName() +
                                ", current value=" + curValue + ", new value=" + value
                );
            }

            makeDirty = false;
        } else {
            pctx.setFieldValue(rowIndex, value);
        }

        if (makeDirty) {
            pctx.setDirty();
        }
    }
View Full Code Here

Examples of org.jboss.as.cmp.jdbc2.PersistentContext

    public String getFieldName() {
        return fieldName;
    }

    public Object getValue(CmpEntityBeanContext ctx) {
        PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
        return pctx.getFieldValue(rowIndex);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.