protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException { ClassDescriptor result = m_cld; String ojbConcreteClass = (String) row.get(OJB_CONCRETE_CLASS_KEY); if(ojbConcreteClass != null) { result = m_cld.getRepository().getDescriptorFor(ojbConcreteClass); // if we can't find class-descriptor for concrete class, something wrong with mapping if (result == null) { throw new PersistenceBrokerException("Can't find class-descriptor for ojbConcreteClass '" + ojbConcreteClass + "', the main class was " + m_cld.getClassNameOfObject()); } } return result; }
protected Object buildOrRefreshObject(Map row, ClassDescriptor targetClassDescriptor, Object targetObject) { Object result = targetObject; FieldDescriptor fmd = null; if(targetObject == null) { // 1. create new object instance if needed // result = ClassHelper.buildNewObjectInstance(targetClassDescriptor); try { result = Class.forName((String) row.get(OJB_CONCRETE_CLASS_KEY)).newInstance(); } catch (Exception e) { throw new PersistenceBrokerException("Unexpected error while try to instantiate concrete PersistentJetspeedPrincipal instance of class: [" +row.get(OJB_CONCRETE_CLASS_KEY), e); } } // 2. fill all scalar attributes of the new object FieldDescriptor[] fields = targetClassDescriptor.getFieldDescriptions(); for (int i = 0; i < fields.length; i++) { fmd = fields[i]; fmd.getPersistentField().set(result, row.get(fmd.getColumnName())); } return result; }
if (result == null || result.length() == 0) throw new PersistenceBrokerException( "ojbConcreteClass field for class " + cld.getClassNameOfObject() + " returned null or 0-length string"); throw new PersistenceBrokerException("Unexpected error while try to read 'ojbConcretClass'" + " field from result set using column name " + fld.getColumnName() + " main class" + " was " + m_cld.getClassNameOfObject(), e);
if (con == null) throw new PersistenceBrokerException("Cannot get connection for " + jcd); if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE) throw new PersistenceBrokerException("Cannot request autoCommit state on the connection", e);
if (!this.isInLocalTransaction) throw new PersistenceBrokerException("Not in transaction, cannot abort");
if (result == null || result.length() == 0) throw new PersistenceBrokerException( "ojbConcreteClass field for class " + cld.getClassNameOfObject() + " returned null or 0-length string"); throw new PersistenceBrokerException("Unexpected error while try to read 'ojbConcretClass'" + " field from result set using column name " + fld.getColumnName() + " main class" + " was " + m_cld.getClassNameOfObject(), e);
@Override public void retrieveReference(Object obj, String pAttributeName) throws PersistenceBrokerException { // In the new version of the fenix-framework, where we use OIDs allover as foreign keys // this method is no longer called for retrieving references to single objects // (those described by an ObjectReferenceDescriptor). // Now, this method should be used only for retrieving collections. // // So, the code here is the merging of the original // PersistenceBrokerImpl.retrieveReference with the // QueryReferenceBroker.retrieveCollection method, changed to // use OIDs rather the primary keys (which remain to be, // still, the idInternal, to create the SQL queries. ClassDescriptor cld = getClassDescriptor(obj.getClass()); CollectionDescriptor cds = cld.getCollectionDescriptorByName(pAttributeName); if (cds == null) { throw new PersistenceBrokerException("In the Fenix Framework retrieveReference should be called only for collections"); } // this collection type will be used: Class collectionClass = cds.getCollectionClass(); Query fkQuery = getFKQuery((AbstractDomainObject) obj, cld, cds); ManageableCollection result = referencesBroker.getCollectionByQuery(collectionClass, fkQuery, false); cds.getPersistentField().set(obj, result); }
logger.error("getSelectByPKStatement returned a null statement"); throw new PersistenceBrokerException("getSelectByPKStatement returned a null statement");
/** * Start transaction on the underlying connection. */ public void localBegin() { if (this.isInLocalTransaction) { throw new TransactionInProgressException("Connection is already in transaction"); } Connection connection = null; try { connection = this.getConnection(); } catch (LookupException e) { /** * must throw to notify user that we couldn't start a connection */ throw new PersistenceBrokerException("Can't lookup a connection", e); } if (log.isDebugEnabled()) log.debug("localBegin was called for con " + connection); if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE) { if (log.isDebugEnabled()) log.debug("Try to change autoCommit state to 'false'"); platform.changeAutoCommitState(jcd, connection, false); } this.isInLocalTransaction = true; }