Package org.objectweb.speedo.api

Examples of org.objectweb.speedo.api.SpeedoException


   */
  private void parseEntityClass(Class c, SpeedoClass sc)
      throws SpeedoException {
    Entity e = (Entity) c.getAnnotation(Entity.class);
    if (e == null) { // This is not an Entity class
      throw new SpeedoException(c.getName()
          + ": should be an annotated EJB3 entity class!");
    }
    logger.log(BasicLevel.DEBUG, "Parse annotation of class: "
        + c.getName());
    // name of the Entity when used in a query
View Full Code Here


                if (jc.targetColumn == null) {
                    if (jc.targetField == null) {
                        if (size == 1) {
                            SpeedoColumn[] cols = getIdColumns(sc);
                            if (cols.length > 1) {
                                throw new SpeedoException("The join to the '"
                                        + join.extTable.name
                                        + "' secondary table has not targetColumn defined and there is several identifier column in the "
                                        + sc.getSourceDesc());
                            }
                            jc.targetColumn = cols[0].name;
                            logger.log(BasicLevel.DEBUG, "\t\tset the target column from the unique PK column: " + jc.targetColumn);
                        } else {
                            throw new SpeedoException("The join columns to the '"
                                    + join.extTable.name
                                    + "' secondary table have not targetColumn defined in the "
                                    + sc.getSourceDesc());
                        }
                    } else {
                        //find the column of the target field
                        SpeedoField sf = sc.getField(jc.targetField);
                        if (sf == null) {
                            throw new SpeedoException("Targeted field '" + jc.targetField + "' in the " + sc.getSourceDesc() + ". It is defined in the join to the secondary table '" + join.extTable.name +"'.");
                        }
                        if (sf.columns == null || sf.columns.length != 1) {
                            throw new SpeedoException("In join column, target field must be a primitive field: " + sf.getSourceDesc() + ". It is defined in the join to the secondary table '" + join.extTable.name +"'.");
                        }
                        jc.targetColumn = sf.columns[0].name;
                    }
                }
            }
View Full Code Here

                }
            } else if (sc.inheritance.strategy == SpeedoInheritance.STRATEGY_SUBCLASS_TABLE) {
                //allocate a temp table
                sc.mainTable = new SpeedoTable();
            } else {
                throw new SpeedoException("Inheritance case not managed, class: "
                        + sc.getSourceDesc());
            }
        }
        if (sc.mainTable.name == null) {
            allocateTableName(sc, sc.mainTable);
View Full Code Here

        }
        if (sc.inheritance.isFilteredMapping()) {
            if (scp.nmf.getNamingManager(sc).needInheritanceDiscriminator(sc)) {
                SpeedoClass ancestor = sc.getAncestor();
                if (ancestor.inheritance == null || ancestor.inheritance.discriminator == null) {
                    throw new SpeedoException("Filtered inheritance requires discriminator defined at root level: " + ancestor.getSourceDesc());
                }
                if (sc.inheritance.discriminatorValues == null) {
                    throw new SpeedoException("Filtered inheritance requires discriminator values defined for each sub class: " + sc.getSourceDesc());
                }
            }
        } else if (sc.inheritance.isHorizontalMapping()) {
            //maps all field of all parents
            List parents = sc.getParents();
View Full Code Here

        }
        //no pk fields and no column defined in sc.identity
        NamingManager nm = scp.nmf.getNamingManager(sc);
        SpeedoColumn[] cols = nm.getDefaultColumn(sc);
        if (cols == null) {
            throw new SpeedoException("no identity mapping for the class '"
                    + sc.getFQName() + "'.");
        }
        sc.identity.setColumns(Arrays.asList(cols));
    }
View Full Code Here

                //compute the target column from the unique pk field
                try {
                    SpeedoField pkField = rclass.getUniquePKField();
                    sf.columns[colIdx].targetColumn = pkField.columns[0].name;
                } catch (SpeedoException e) {
                    throw new SpeedoException("Bad number of column specified for the " + sf.getSourceDesc(), e);
                }
            } else {
                SpeedoException se = new SpeedoException("Target column is required for the reference " + sf.getSourceDesc());
                logger.log(BasicLevel.ERROR, se.getMessage(), se);
                throw se;
            }
        } else {
            //compute the target column from the target field
            SpeedoField pkField = rclass.getField(sf.columns[colIdx].targetField);
View Full Code Here

            if (nbcol == 1) {
                //compute the target column from the unique pk field
                SpeedoField pkField = sf.moClass.getUniquePKField();
                jc.targetColumn = pkField.columns[0].name;
            } else {
                SpeedoException se = new SpeedoException("Target column is required for join column of the reference " + sf.getSourceDesc());
                logger.log(BasicLevel.ERROR, se.getMessage(), se);
                throw se;
            }
        } else {
            //compute the target column from the target field
            SpeedoField pkField = sf.moClass.getField(jc.targetField);
View Full Code Here

     */
    private Class getGCClass(SpeedoField sf) throws SpeedoException {
        try {
            return Class.forName(sf.type());
        } catch (ClassNotFoundException e) {
            throw new SpeedoException("Class loading problem: ", e);
        }
    }
View Full Code Here

        }
        UserIDClassAnalyzer uica = new UserIDClassAnalyzer(logger);
        loader.loadJavaClass(isSrcJar, className, _scp.output,false)
                .accept(uica, true);
        if (uica.fieldNames.isEmpty()) {
            throw new SpeedoException("The identifier class '"
                    + sc.identity.objectidClass + "' has no public field.");
        }
        if (sc.getSuperClassName() != null) {
      //do nothing, the primary key field are inherited from the ancestor
    } else if (pkfields.isEmpty()) {
            for(int i=0; i<uica.fieldNames.size(); i++) {
                SpeedoField sf = (SpeedoField) sc.fields.get(uica.fieldNames.get(i));
                if (sf == null) {
                    logger.log(BasicLevel.WARN, "The public field '"
                            + uica.fieldNames.get(i) + "' of the identifier class "
                            + className + "' does not match to any field in the persistent class '"
                            + sc.getFQName() +"'.");
                    continue;
                }
                if (!sf.type.equals(uica.fieldTypes.get(i))) {
                    throw new SpeedoException("The field '" + sf.name
                            + "' has not the same type in identifier class '"
                            + className + "' ("
                            + Util.type(Type.getType((String) uica.fieldTypes.get(i)))
                            + ") and in the persistent class '" + sc.getFQName()
                            + "' (" + Util.type(Type.getType(sf.type)) + ").");
                }
                sf.primaryKey = true;
            }
        } else {
            //check that the lists are the same
            for(int i=0; i<pkfields.size(); i++) {
                if (!uica.fieldNames.contains(((SpeedoField) pkfields.get(i)).name)) {
                    logger.log(BasicLevel.ERROR, "uica.fieldNames:\n" + uica.fieldNames);
                    logger.log(BasicLevel.ERROR, "pkfields:\n" + pkfields);
                    throw new SpeedoException("The field '" + pkfields.get(i)
                            + "' is marked primary-key=true whereas it is not "
                            + "defined in the identifier class '" + className
                            + "' associated to the persistent class '"
                            + sc.getFQName() + "'.");
                }
View Full Code Here

            //Register the meta information to serialize for each xml descriptor
            for (Iterator itDesc = scp.getXmldescriptor().values().iterator(); itDesc.hasNext();) {
                addSerializeJormMI((SpeedoXMLDescriptor) itDesc.next());
            }
        } catch (PException e) {
            throw new SpeedoException("Error during Jorm generation", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.api.SpeedoException

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.