Package javango.db

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


  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

  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

        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

  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

      }
    } else if ("notin".equals(searchType)) {
      return Restrictions.not(Restrictions.in(searchField, (Object[])searchValue));
    } else if ("date".equals(searchType)) {
      if (!(searchValue instanceof Date) || searchValue == null) {
        throw new ManagerException ("__date search requires a non-null instance of java.util.Date");
      }
      Date date = (Date)searchValue;
     
      Calendar from = new GregorianCalendar();
      from.setTime(date);
View Full Code Here

  public String getPkProperty() 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) {
View Full Code Here

    Manager<T> manager = Managers().forClass(model);
   
    try {
      return manager.get(key);
    } catch (ManagerException e) {
      throw new ManagerException(String.format("A database eror occurred while getting an instance of '%s' with key '%s'", model.getName(), key));
    }
  }
View Full Code Here

    Manager<T> manager = Managers().forClass(model);
   
    try {
      return manager.filter(field, value).get();
    } catch (ManagerException e) {
      throw new ManagerException(String.format("A database eror occurred while getting an instance of '%s' with %s='%s'", model.getName(), field, value));
    }
  }
View Full Code Here

TOP

Related Classes of javango.db.ManagerException

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.