Package org.hibernate

Examples of org.hibernate.MappingException


      /**
       * Returns the identifier type of a mapped class
       */
      public Type getIdentifierType(String persistentClass) throws MappingException {
        PersistentClass pc = cfg.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 = cfg.getClassMapping( persistentClass );
        if (pc==null) throw new MappingException("persistent class not known: " + persistentClass);
        if ( !pc.hasIdentifierProperty() ) return null;
        return pc.getIdentifierProperty().getName();
      }

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

      public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
        return null;
View Full Code Here


        if(collection.isOneToMany() ) {
            OneToMany oneToMany = (OneToMany) collection.getElement();
            PersistentClass persistentClass = mappings.getClass(oneToMany.getReferencedEntityName() );

            if (persistentClass==null) throw new MappingException(
                    "Association " + collection.getRole() + " references unmapped class: " + oneToMany.getReferencedEntityName()
                );

            oneToMany.setAssociatedClass(persistentClass); // Child
        }
View Full Code Here

        ( ( Configurable ) idgen ).configure( type, params, dialect );
      }
      return idgen;
    }
    catch ( Exception e ) {
      throw new MappingException(
          "could not instantiate id generator [entity-name=" + params.get(
              IdentifierGenerator.ENTITY_NAME
          ) + "]", e
      );
    }
View Full Code Here

      if ( clazz == null ) {
        clazz = ReflectHelper.classForName( strategy );
      }
    }
    catch ( ClassNotFoundException e ) {
      throw new MappingException( "could not interpret id generator strategy: " + strategy );
    }
    return clazz;
  }
View Full Code Here

   * @return The appropriate CascadeStyle
   */
  public static CascadeStyle getCascadeStyle(String cascade) {
    CascadeStyle style = (CascadeStyle) STYLES.get(cascade);
    if (style==null) {
      throw new MappingException("Unsupported cascade style: " + cascade);
    }
    else {
      return style;
    }
  }
View Full Code Here

  public Class getListenerClassFor(String type) {
    Class clazz = (Class) eventInterfaceFromType.get(type);
   
    if (clazz == null) {
      throw new MappingException("Unrecognized listener type [" + type + "]");
    }

    return clazz;
  }
View Full Code Here

    Constructor pc;
    try {
      pc = persisterClass.getConstructor( PERSISTER_CONSTRUCTOR_ARGS );
    }
    catch ( Exception e ) {
      throw new MappingException( "Could not get constructor for " + persisterClass.getName(), e );
    }

    try {
      return (EntityPersister) pc.newInstance( new Object[] { model, cacheAccessStrategy, factory, cfg } );
    }
    catch (InvocationTargetException ite) {
      Throwable e = ite.getTargetException();
      if (e instanceof HibernateException) {
        throw (HibernateException) e;
      }
      else {
        throw new MappingException( "Could not instantiate persister " + persisterClass.getName(), e );
      }
    }
    catch (Exception e) {
      throw new MappingException( "Could not instantiate persister " + persisterClass.getName(), e );
    }
  }
View Full Code Here

    Constructor pc;
    try {
      pc = persisterClass.getConstructor( COLLECTION_PERSISTER_CONSTRUCTOR_ARGS );
    }
    catch (Exception e) {
      throw new MappingException( "Could not get constructor for " + persisterClass.getName(), e );
    }

    try {
      return (CollectionPersister) pc.newInstance( new Object[] { model, cacheAccessStrategy, cfg, factory } );
    }
    catch (InvocationTargetException ite) {
      Throwable e = ite.getTargetException();
      if (e instanceof HibernateException) {
        throw (HibernateException) e;
      }
      else {
        throw new MappingException( "Could not instantiate collection persister " + persisterClass.getName(), e );
      }
    }
    catch (Exception e) {
      throw new MappingException( "Could not instantiate collection persister " + persisterClass.getName(), e );
    }
  }
View Full Code Here

   *
   * @return The appropriate select command
   * @throws MappingException If IDENTITY generation is not supported.
   */
  protected String getIdentitySelectString() throws MappingException {
    throw new MappingException( "Dialect does not support identity key generation" );
  }
View Full Code Here

   *
   * @return The appropriate DDL fragment.
   * @throws MappingException If IDENTITY generation is not supported.
   */
  protected String getIdentityColumnString() throws MappingException {
    throw new MappingException( "Dialect does not support identity key generation" );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.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.