Package org.jboss.as.cmp.jdbc2.keygen

Examples of org.jboss.as.cmp.jdbc2.keygen.PostgreSQLCreateCommand


                EJBLocalObject value = (EJBLocalObject) getValue(ctx);
                if (value != null) {
                    changeValue(null);

                    final Object relatedId = value.getPrimaryKey();
                    final JDBCStoreManager2 relatedManager = (JDBCStoreManager2) relatedEntity.getManager();

                    if (!relatedManager.isCascadeDeleted(relatedId)) {
                        value.remove();
                    }
                }

                manager.unregisterCascadeDelete(ctx.getPrimaryKey());
View Full Code Here


    public Method getMethod() {
        return metadata.getMethod();
    }

    public Object execute(CmpEntityBeanContext ctx, Object[] args) throws FinderException {
        JDBCStoreManager2 manager = command.getStoreManager();
        final CmpEntityBeanComponent selectedComponent = manager.getComponent();
        JDBCQueryCommand.EntityProxyFactory factory = new JDBCQueryCommand.EntityProxyFactory() {
            public Object getEntityObject(Object primaryKey) {
                return metadata.isResultTypeMappingLocal() && selectedComponent.getLocalHomeClass() != null ?
                        selectedComponent.getEJBLocalObject(primaryKey) : selectedComponent.getEJBObject(primaryKey);
            }
View Full Code Here

                EJBLocalObject value = (EJBLocalObject) getValue(ctx);
                if (value != null) {
                    changeValue(null);

                    final Object relatedId = value.getPrimaryKey();
                    final JDBCStoreManager2 relatedManager = (JDBCStoreManager2) relatedEntity.getManager();

                    if (!relatedManager.isCascadeDeleted(relatedId)) {
                        value.remove();
                    }
                }

                manager.unregisterCascadeDelete(ctx.getPrimaryKey());
View Full Code Here

                EJBLocalObject value = (EJBLocalObject) getValue(ctx);
                if (value != null) {
                    changeValue(null);

                    final Object relatedId = value.getPrimaryKey();
                    final JDBCStoreManager2 relatedManager = (JDBCStoreManager2) relatedEntity.getManager();

                    if (!relatedManager.isCascadeDeleted(relatedId)) {
                        value.remove();
                    }
                }

                manager.unregisterCascadeDelete(ctx.getPrimaryKey());
View Full Code Here

    public Method getMethod() {
        return metadata.getMethod();
    }

    public Object execute(CmpEntityBeanContext ctx, Object[] args) throws FinderException {
        JDBCStoreManager2 manager = command.getStoreManager();
        final CmpEntityBeanComponent selectedComponent = manager.getComponent();
        JDBCQueryCommand.EntityProxyFactory factory = new JDBCQueryCommand.EntityProxyFactory() {
            public Object getEntityObject(Object primaryKey) {
                return metadata.isResultTypeMappingLocal() && selectedComponent.getLocalHomeClass() != null ?
                        selectedComponent.getEjbLocalObject(primaryKey) : selectedComponent.getEJBObject(primaryKey);
            }
View Full Code Here

                EJBLocalObject value = (EJBLocalObject) getValue(ctx);
                if (value != null) {
                    changeValue(null);

                    final Object relatedId = value.getPrimaryKey();
                    final JDBCStoreManager2 relatedManager = (JDBCStoreManager2) relatedEntity.getManager();

                    if (!relatedManager.isCascadeDeleted(relatedId)) {
                        value.remove();
                    }
                }

                manager.unregisterCascadeDelete(ctx.getPrimaryKeyUnchecked());
View Full Code Here

                EJBLocalObject value = (EJBLocalObject) getValue(ctx);
                if (value != null) {
                    changeValue(null);

                    final Object relatedId = value.getPrimaryKey();
                    final JDBCStoreManager2 relatedManager = (JDBCStoreManager2) relatedEntity.getManager();

                    if (!relatedManager.isCascadeDeleted(relatedId)) {
                        value.remove();
                    }
                }

                manager.unregisterCascadeDelete(ctx.getPrimaryKeyUnchecked());
View Full Code Here

        this.pkSql = "";
    }

    public Object execute(Method m, Object[] args, CmpEntityBeanContext ctx) throws CreateException {
        Object pk;
        PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
        if (ctx.getPrimaryKey() == null) {
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            try {
                if (log.isDebugEnabled()) {
                    log.debug("executing sql: " + pkSql);
                }

                con = entityBridge.getDataSource().getConnection();
                ps = con.prepareStatement(pkSql);
                rs = ps.executeQuery();

                if (!rs.next()) {
                    throw CmpMessages.MESSAGES.pkSqlReturnedNoResults(pkSql);
                }

                pk = pkField.loadArgumentResults(rs, 1);
                pctx.setFieldValue(pkField.getRowIndex(), pk);
                pk = entityBridge.extractPrimaryKeyFromInstance(ctx);
            } catch (SQLException e) {
                throw CmpMessages.MESSAGES.failedToExecutePkSql(e);
            } finally {
                JDBCUtil.safeClose(rs);
                JDBCUtil.safeClose(ps);
                JDBCUtil.safeClose(con);
            }

            if (pk == null) {
                throw CmpMessages.MESSAGES.pkIsNullForCreatedInstance();
            }

            pctx.setPk(pk);
        } else {
            // insert-after-ejb-post-create
            try {
                pctx.flush();
            } catch (SQLException e) {
                if ("23000".equals(e.getSQLState())) {
                    throw CmpMessages.MESSAGES.uniqueKeyViolation(ctx.getPrimaryKey());
                } else {
                    throw CmpMessages.MESSAGES.failedToCreateInstance(ctx.getPrimaryKey(), e);
View Full Code Here

            relatedPKFields = null;
        }
    }

    private FieldState getFieldState(CmpEntityBeanContext ctx) {
        PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
        FieldState state = pctx.getCMRState(cmrIndex);
        if (state == null) {
            if (isSingleValued()) {
                state = new SingleValuedFieldState();
            } else {
                state = new CollectionValuedFieldState();
            }
            pctx.setCMRState(cmrIndex, state);
        }
        return state;
    }
View Full Code Here

        public Object getCachedValue() {
            return value == null ? NULL_VALUE : value;
        }

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

TOP

Related Classes of org.jboss.as.cmp.jdbc2.keygen.PostgreSQLCreateCommand

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.