Examples of ManagerException


Examples of javango.db.ManagerException

  public void delete(T object) throws ManagerException {
    try {
      hibernateUtil.getSession().delete(object);
    } catch (HibernateException e) {
      throw new ManagerException(e);
    }

  }
View Full Code Here

Examples of javango.db.ManagerException

  public T get(Serializable key) throws ManagerException {
    if (key == null) return null;
   
    Class<?>[] keyClass = getPkClass();
    if (keyClass.length != 1) {
      throw new ManagerException("get(pk) not supported for composite keyed models");
    }   
    if (key.getClass().equals(keyClass[0])) {
      return (T) hibernateUtil.getSession().get(model, key);
    }   
   
View Full Code Here

Examples of javango.db.ManagerException

  public T save(T object) throws ManagerException {
    try {
      hibernateUtil.getSession().saveOrUpdate(object);
    } catch (HibernateException e) {
      throw new ManagerException(e);
    }
    return object;
  }
View Full Code Here

Examples of javango.db.ManagerException

 
  public T create(T object) throws ManagerException {
    try {
      hibernateUtil.getSession().save(object);
    } catch (HibernateException e) {
      throw new ManagerException(e);
    }
    return object;
  }
View Full Code Here

Examples of javango.db.ManagerException

  public Serializable getPk(T object) throws ManagerException {
    try {
      return hibernateUtil.getSession().getIdentifier(object);
    } catch (HibernateException e) {
      // TODO Throw something cool here and elsewhere...
      throw new ManagerException(e);
    }
  }
View Full Code Here

Examples of javango.db.ManagerException

  public Class[] getPkClass() throws ManagerException {
    Configuration cfg = hibernateUtil.getConfiguration();
    PersistentClass pclass = cfg.getClassMapping(model.getName());

    if (pclass == null) {
      throw new ManagerException("Unable to find class : "+ model.toString());
    }

    Property componentProperty = pclass.getIdentifierProperty();
    if (componentProperty == null) {
      Component component = pclass.getIdentifierMapper();
      if (component == null) {
        throw new ManagerException("Unable to get pk mapping");
      }
//      if (log.isDebugEnabled()) log.debug(String.format("Found %d keys for model %s", component.getPropertySpan(), model.getName()));

      Class<?>[] classArray = new Class[component.getColumnSpan()];
      Iterator<Property> ite = component.getPropertyIterator();
      int i = 0;
      while (ite.hasNext()) {
        Property p = ite.next();
//        if (log.isDebugEnabled()) log.debug("property name: " + p.getName());
        classArray[i++] = p.getType().getReturnedClass();
      }
      return classArray;
    } else {

      Value value = componentProperty.getValue();
      if (value == null)
        throw new ManagerException("Component value is null");
      else {
//        if (log.isDebugEnabled()) log.debug(String.format("Found simple key for model %s '%s'",  model.getName(), value.getType().getReturnedClass()));
        return new Class[] { value.getType().getReturnedClass() };
      }
    }
View Full Code Here

Examples of javango.db.ManagerException

  public String getPkProperty() throws ManagerException {
    Configuration cfg = hibernateUtil.getConfiguration();
    PersistentClass pclass = cfg.getClassMapping(model.getName());

    if (pclass == null) {
      throw new ManagerException("Unable to find class : "
          + model.toString());
    }

    Property componentProperty = pclass.getIdentifierProperty();
    if (componentProperty == null) {
View Full Code Here

Examples of javango.db.ManagerException

  public Class[] getPkClass() throws ManagerException {
    Configuration cfg = hibernateUtil.getConfiguration();
    PersistentClass pclass = cfg.getClassMapping(modelClass.getName());

    if (pclass == null) {
      throw new ManagerException("Unable to find class : "
          + modelClass.toString());
    }

    Property componentProperty = pclass.getIdentifierProperty();
    if (componentProperty == null) {
      Component component = pclass.getIdentifierMapper();
      if (component == null) {
        throw new ManagerException("Unable to get pk mapping");
      }
      if (log.isDebugEnabled()) log.debug(String.format("Found %d keys for model %s", component.getPropertySpan(), modelClass.getName()));

      Class<?>[] classArray = new Class[component.getColumnSpan()];
      Iterator<Property> ite = component.getPropertyIterator();
      int i = 0;
      while (ite.hasNext()) {
        Property p = ite.next();
        if (log.isDebugEnabled()) log.debug("property name: " + p.getName());
        classArray[i++] = p.getType().getReturnedClass();
      }
      return classArray;
    } else {

      Value value = componentProperty.getValue();
      if (value == null)
        throw new ManagerException("Component value is null");
      else {
        if (log.isDebugEnabled()) log.debug(String.format("Found simple key for model %s '%s'",
            modelClass.getName(), value.getType()
                .getReturnedClass()));
        return new Class[] { value.getType().getReturnedClass() };
View Full Code Here

Examples of javango.db.ManagerException

        return classToTry.getDeclaredField(property);
      } catch (NoSuchFieldException e) {
        classToTry = classToTry.getSuperclass();
      }
    }
    throw new ManagerException("No such field found: " + property + " in class " + modelClass.getName());
  }
View Full Code Here

Examples of javango.db.ManagerException

  public Object convertToPk(Object pk) throws ManagerException {
  if (pk == null) return null;
   
    Class[] keyClass = getPkClass();
    if (keyClass.length != 1) {
      throw new ManagerException("get(pk) not supported for composite keyed models");
    }
       
    if (pk.getClass().equals(keyClass[0])) {
      return pk;
    }   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.