Package net.sf.hibernate4gwt.exception

Examples of net.sf.hibernate4gwt.exception.TransientHibernateObjectException


    if (hibernateMetadata == null)
    {
    //  Component class (persistent but not metadata) : no associated id
    //  So must be considered as transient
    //
      throw new TransientHibernateObjectException(pojo);
    }
   
  //  Retrieve ID
  //
    Serializable id = null;
   
    if (hibernateClass.equals(pojo.getClass()))
    {
    //  the pojo has the same class, simple use metadata
    //
      id = hibernateMetadata.getIdentifier(pojo, EntityMode.POJO)
    }
    else
    {
    //  DTO case : invoke the method with the same name
    //
      String property = hibernateMetadata.getIdentifierPropertyName();
     
      try
      {
        // compute getter method name
        property = property.substring(0,1).toUpperCase() +
               property.substring(1);
        String getter = "get" + property;
       
        // Find getter method
        Class<?> pojoClass = pojo.getClass();
        Method method = pojoClass.getMethod(getter, (Class[])null);
        if (method == null)
        {
          throw new RuntimeException("Cannot find method " + getter + " for Class<?> " + pojoClass);
        }
        id = (Serializable) method.invoke(pojo,(Object[]) null);
      }
      catch (Exception ex)
      {
        throw new RuntimeException("Invocation exception ", ex);
      }
    }
   
  //  Post condition checking
  //
    if (id == null)
    {
      throw new TransientHibernateObjectException(pojo);
    }
    return id;
  }
View Full Code Here

TOP

Related Classes of net.sf.hibernate4gwt.exception.TransientHibernateObjectException

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.