Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.MappingException


     *         file.
     */
    public static JDOManager createInstance(final String databaseName)
    throws MappingException {
        if (!DatabaseRegistry.hasDatabaseRegistries()) {
            throw new MappingException(Messages.message(
                    "jdo.missing.jdo.configuration"));
        }
       
        if (!DatabaseRegistry.isDatabaseRegistred(databaseName)) {
            throw new MappingException(Messages.format(
                    "jdo.missing.database.configuration", databaseName));
        }
           
        JDOManager jdoInstance = (JDOManager) _jdoInstances.get(databaseName);
       
View Full Code Here


                query.addParameter(_mapTo, ids[i].getName(), QueryExpression.OP_EQUALS);
            }
            _statement = query.getStatement(true);
      } catch (QueryException except) {
          LOG.warn("Problem building SQL", except);
          throw new MappingException(except);
      }
    }
View Full Code Here

        _fieldDescriptor = fieldDesc;
       
        ClassDescriptor related = fieldDesc.getClassDescriptor();
        if (related != null) {
            if (!(related.hasNature(ClassDescriptorJDONature.class.getName()))) {
                throw new MappingException("Related class is not JDOClassDescriptor");
            }

            FieldDescriptor[] relids = ((ClassDescriptorImpl) related).getIdentities();
            String[] relnames = new String[relids.length];
            for (int i = 0; i < relids.length; i++) {
                relnames[i] = new FieldDescriptorJDONature(relids[i]).getSQLName()[0];
                if (relnames[i] == null) {
                    throw new MappingException("Related class identities field does "
                            + "not contains sql information!");
                }
            }
           
            FieldDescriptor[] classids = ((ClassDescriptorImpl) clsDesc).getIdentities();
            String[] classnames = new String[classids.length];
            for (int i = 0; i < classids.length; i++) {
                classnames[i] = new FieldDescriptorJDONature(classids[i]).getSQLName()[0];
                if (classnames[i] == null) {
                    throw new MappingException("Related class identities field does "
                            + "not contains sql information!");
                }
            }

            String[] names = relnames;
            if (!(fieldDesc.hasNature(FieldDescriptorJDONature.class.getName()))) {
                _tableName = new ClassDescriptorJDONature(related).getTableName();
                _store = false;
                _multi = fieldDesc.isMultivalued();
                _joined = true;
                _joinFields = classnames;
                _dirtyCheck = true;
            } else {
                final FieldDescriptorJDONature jdoFieldNature =
                    new FieldDescriptorJDONature(fieldDesc);

                names = jdoFieldNature.getSQLName();
                if ((names != null) && (names.length != relids.length)) {
                    throw new MappingException("The number of column of foreign keys "
                            + "doesn't not match with what specified in manyKey");
                }
                names = (names != null) ? names : relnames;

                String[] joins = jdoFieldNature.getManyKey();
                if ((joins != null) && (joins.length != classids.length)) {
                    throw new MappingException("The number of column of foreign keys "
                            + "doesn't not match with what specified in manyKey");
                }

                if (jdoFieldNature.getManyTable() != null) {
                    _tableName = jdoFieldNature.getManyTable();
                    _store = false;
                    _multi = fieldDesc.isMultivalued();
                    _joined = true;
                    _joinFields = (joins != null) ? joins : classnames;
                } else if (jdoFieldNature.getSQLName() != null) {
                    _tableName = classTable;
                    _store = !ext && !jdoFieldNature.isReadonly();
                    _multi = false;
                    _joined = false;
                    _joinFields = classnames;
                } else {
                    _tableName = new ClassDescriptorJDONature(related).getTableName();
                    _store = false;
                    _multi = fieldDesc.isMultivalued();
                    _joined = true;
                    _joinFields = (joins != null) ? joins : classnames;
                }

                _dirtyCheck = jdoFieldNature.isDirtyCheck();
            }

            _columns = new SQLColumnInfo[relids.length];
            for (int i = 0; i < relids.length; i++) {
                if (!(relids[i].hasNature(FieldDescriptorJDONature.class.getName()))) {
                    throw new MappingException("Related class identities field does "
                            + "not contains sql information!");
                }

                FieldDescriptor relId = relids[i];
                FieldHandlerImpl fh = (FieldHandlerImpl) relId.getHandler();
View Full Code Here

            if (source == null) { source = new InputSource(url); }
            if (source.getSystemId() == null) { source.setSystemId(url); }
            LOG.info(Messages.format("mapping.loadingFrom", url));
            loadMappingInternal(mapping, resolver, source);
        } catch (SAXException ex) {
            throw new MappingException(ex);
        }
    }
View Full Code Here

                Include include = (Include) includes.nextElement();
                if (!mapping.processed(include.getHref())) {
                    try {
                        loadMappingInternal(mapping, resolver, include.getHref());
                    } catch (Exception ex) {
                        throw new MappingException(ex);
                    }
                }
            }
           
            // gather "class" tags
            Enumeration enumeration = loaded.enumerateClassMapping();
            while (enumeration.hasMoreElements()) {
                root.addClassMapping((ClassMapping) enumeration.nextElement());
            }

            // gather "key-generator" tags
            enumeration = loaded.enumerateKeyGeneratorDef();
            while (enumeration.hasMoreElements()) {
                root.addKeyGeneratorDef((KeyGeneratorDef) enumeration.nextElement());
            }
           
            // gather "field-handler" tags
            root.setFieldHandlerDef(loaded.getFieldHandlerDef());

        } catch (Exception ex) {
            throw new MappingException(ex);
        }
    }
View Full Code Here

        }
       
        String msg = "No mapping loader/factory for: " + "SourceType=" + sourceType
                   + " / BindingType=" + bindingType;
        LOG.error(msg);
        throw new MappingException(msg);
    }
View Full Code Here

                    }
                }
                idsInfo.add(new SQLColumnInfo(sqlName[0], sqlType[0], fh.getConvertTo(),
                        fh.getConvertFrom()));
            } else {
                throw new MappingException("Except JDOFieldDescriptor");
            }
        }

        // then do the fields
        while (!stack.empty()) {
View Full Code Here

           
            if (!success || (cause != null)) {
                String msg = Messages.format("jdo.engine.datasourceParaFail",
                                             params[j].getName(), value);
                LOG.error(msg, cause);
                throw new MappingException(msg, cause);
            }
        }
    }
View Full Code Here

        try {
            unmarshaller.setEntityResolver(new DTDResolver(resolver));
            jdoConf = (JdoConf) unmarshaller.unmarshal(source);
        } catch (MarshalException e) {
            LOG.info(NOTE_096);
            throw new MappingException(e);
        } catch (ValidationException e) {
            throw new MappingException(e);
        }

        return jdoConf;
    }
View Full Code Here

            TransactionManagerRegistry txr = new TransactionManagerRegistry(properties);
            try {
                txr.registerTransactionManager(name, txm, prop);
                _txManager = txr.getTransactionManager(name);
            } catch (TransactionManagerAcquireException ex) {
                throw new MappingException(ex);
            }
           
            initializeEngine(_jdoConf.getDatabase(_index).getEngine());
            initializeFactory();
           
View Full Code Here

TOP

Related Classes of org.exolab.castor.mapping.MappingException

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.