Example usage for org.hibernate MappingException MappingException

List of usage examples for org.hibernate MappingException MappingException

Introduction

In this page you can find the example usage for org.hibernate MappingException MappingException.

Prototype

public MappingException(String message) 

Source Link

Document

Constructs a MappingException using the given information.

Usage

From source file:com.floreantpos.model.EnumUserType.java

License:Open Source License

public void setParameterValues(Properties params) {
    String enumClassName = params.getProperty("enumClassName"); //$NON-NLS-1$
    if (enumClassName == null) {
        throw new MappingException(Messages.getString("EnumUserType.0")); //$NON-NLS-1$
    }//from  w  ww  . ja va 2 s  .  c  o  m

    try {
        this.clazz = Class.forName(enumClassName);
    } catch (ClassNotFoundException e) {
        throw new MappingException("enumClass " + enumClassName + " not found", e); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:com.hyron.poscafe.util.ConfigurationWithWildcard.java

License:Open Source License

private void parseListener(Element element) {
    String type = element.attributeValue("type");
    if (type == null) {
        throw new MappingException("No type specified for listener");
    }//from   ww w .  j ava  2 s . c om
    String impl = element.attributeValue("class");
    log.debug("Event listener: " + type + "=" + impl);
    setListeners(type, new String[] { impl });
}

From source file:com.netspective.tool.hibernate.document.diagram.HibernateDiagramGenerator.java

License:Open Source License

public HibernateDiagramGenerator(final Configuration configuration,
        final GraphvizDiagramGenerator graphvizDiagramGenerator,
        final HibernateDiagramGeneratorFilter schemaDiagramFilter) throws HibernateDiagramGeneratorException {
    this.configuration = configuration;
    this.graphvizDiagramGenerator = graphvizDiagramGenerator;
    this.diagramFilter = schemaDiagramFilter;

    // the following was copied from org.hibernate.cfg.Configuration.buildMapping() because buildMapping() was private
    this.mapping = new Mapping() {
        /**/* w ww.  j a  va  2  s  . c  o  m*/
         * Returns the identifier type of a mapped class
         */
        public Type getIdentifierType(String persistentClass) throws MappingException {
            final PersistentClass pc = configuration.getClassMapping(persistentClass);
            if (pc == null)
                throw new MappingException("persistent class not known: " + persistentClass);
            return pc.getIdentifier().getType();
        }

        public String getIdentifierPropertyName(String persistentClass) throws MappingException {
            final PersistentClass pc = configuration.getClassMapping(persistentClass);
            if (pc == null)
                throw new MappingException("persistent class not known: " + persistentClass);
            if (!pc.hasIdentifierProperty())
                return null;
            return pc.getIdentifierProperty().getName();
        }

        public Type getPropertyType(String persistentClass, String propertyName) throws MappingException {
            final PersistentClass pc = configuration.getClassMapping(persistentClass);
            if (pc == null)
                throw new MappingException("persistent class not known: " + persistentClass);
            Property prop = pc.getProperty(propertyName);
            if (prop == null)
                throw new MappingException("property not known: " + persistentClass + '.' + propertyName);
            return prop.getType();
        }
    };

    String dialectName = configuration.getProperty(Environment.DIALECT);
    if (dialectName == null)
        dialectName = org.hibernate.dialect.GenericDialect.class.getName();

    try {
        final Class cls = Class.forName(dialectName);
        this.dialect = (Dialect) cls.newInstance();
    } catch (Exception e) {
        throw new HibernateDiagramGeneratorException(e);
    }

    for (final Iterator classes = configuration.getClassMappings(); classes.hasNext();) {
        final PersistentClass pclass = (PersistentClass) classes.next();
        final Table table = (Table) pclass.getTable();

        tableToClassMap.put(table, pclass);
    }
}

From source file:com.vmware.sqlfire.hibernate.SQLFireDialectBase.java

License:Open Source License

@Override
public String getSequenceNextValString(String sequenceName) throws MappingException {
    throw new MappingException("Sqlfire Dialect does not support sequences");
}

From source file:com.zutubi.pulse.master.hibernate.MutableConfiguration.java

License:Apache License

public Mapping getMapping() {
    return new Mapping() {
        public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
            return null;
        }/*from w w w.j  a va2 s .co  m*/

        public Type getIdentifierType(String persistentClass) throws MappingException {
            PersistentClass pc = classes.get(persistentClass);
            if (pc == null) {
                throw new MappingException(I18N.format("unknown.persistent.class", persistentClass));
            }
            return pc.getIdentifier().getType();
        }

        public String getIdentifierPropertyName(String persistentClass) throws MappingException {
            final PersistentClass pc = classes.get(persistentClass);
            if (pc == null) {
                throw new MappingException(I18N.format("unknown.persistent.class", persistentClass));
            }
            if (!pc.hasIdentifierProperty())
                return null;
            return pc.getIdentifierProperty().getName();
        }

        public Type getReferencedPropertyType(String persistentClass, String propertyName)
                throws MappingException {
            final PersistentClass pc = classes.get(persistentClass);
            if (pc == null) {
                throw new MappingException(I18N.format("unknown.persistent.class", persistentClass));
            }
            Property prop = pc.getReferencedProperty(propertyName);
            if (prop == null) {
                throw new MappingException(
                        I18N.format("unknown.persistent.class.property", persistentClass + '.' + propertyName));
            }
            return prop.getType();
        }
    };
}

From source file:com.zutubi.pulse.master.transfer.jdbc.HibernateMapping.java

License:Apache License

public Type getIdentifierType(String persistentClass) throws MappingException {
    PersistentClass pc = configuration.getClassMapping(persistentClass);
    if (pc == null) {
        throw new MappingException("persistent class not known: " + persistentClass);
    }//from w  ww.j  ava 2  s . co  m
    return pc.getIdentifier().getType();
}

From source file:com.zutubi.pulse.master.transfer.jdbc.HibernateMapping.java

License:Apache License

public String getIdentifierPropertyName(String persistentClass) throws MappingException {
    final PersistentClass pc = configuration.getClassMapping(persistentClass);
    if (pc == null) {
        throw new MappingException("persistent class not known: " + persistentClass);
    }/*from  w ww  . j a va  2  s .c o  m*/
    if (!pc.hasIdentifierProperty())
        return null;
    return pc.getIdentifierProperty().getName();
}

From source file:com.zutubi.pulse.master.transfer.jdbc.HibernateMapping.java

License:Apache License

public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException {
    final PersistentClass pc = configuration.getClassMapping(persistentClass);
    if (pc == null) {
        throw new MappingException("persistent class not known: " + persistentClass);
    }//w w  w .j  av a2 s.c o  m
    Property prop = pc.getReferencedProperty(propertyName);
    if (prop == null) {
        throw new MappingException("property not known: " + persistentClass + '.' + propertyName);
    }
    return prop.getType();
}

From source file:cpcc.core.services.UniqueIntegerIdGenerator.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w  w w.j  a  va  2s .  c o  m*/
 */
@Override
public void configure(Type type, Properties params, Dialect d) throws MappingException {
    entityName = params.getProperty(ENTITY_NAME);
    if (entityName == null) {
        throw new MappingException("no entity name");
    }
}

From source file:gov.nih.nci.caintegrator.util.EnumUserType.java

License:BSD License

public void setParameterValues(Properties params) {
    String enumClassName = params.getProperty("enumClassName");
    if (enumClassName == null) {
        throw new MappingException("enumClassName parameter not specified");
    }//from ww  w. j  av a 2s  . c  o  m

    try {
        this.clazz = Class.forName(enumClassName);
    } catch (java.lang.ClassNotFoundException e) {
        throw new MappingException("enumClass " + enumClassName + " not found", e);
    }
}