[jboss-cvs] jboss-seam/src/main/org/jboss/seam/util ...

Gavin King gavin.king at jboss.com
Wed Sep 27 19:14:42 EDT 2006


  User: gavin   
  Date: 06/09/27 19:14:42

  Modified:    src/main/org/jboss/seam/util  Persistence.java
  Log:
  propagate page parameters across navigation rule redirects
  improvements to framework
  
  Revision  Changes    Path
  1.4       +34 -2     jboss-seam/src/main/org/jboss/seam/util/Persistence.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Persistence.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/util/Persistence.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Persistence.java	23 Sep 2006 16:31:48 -0000	1.3
  +++ Persistence.java	27 Sep 2006 23:14:42 -0000	1.4
  @@ -10,7 +10,7 @@
   
      public static void setFlushModeManual(EntityManager entityManager)
      {
  -      if (entityManager instanceof Session)
  +      if (entityManager.getDelegate() instanceof Session)
         {
            ( (Session) entityManager.getDelegate() ).setFlushMode(FlushMode.NEVER);
         }
  @@ -22,7 +22,7 @@
   
      public static boolean isDirty(EntityManager entityManager)
      {
  -      if (entityManager instanceof Session)
  +      if (entityManager.getDelegate() instanceof Session)
         {
            return ( (Session) entityManager.getDelegate() ).isDirty();
         }
  @@ -32,4 +32,36 @@
         }
      }
   
  +   public static Object getId(Object bean, EntityManager entityManager) throws Exception
  +   {
  +      if (entityManager.getDelegate() instanceof Session)
  +      {
  +         return ( (Session) entityManager.getDelegate() ).getIdentifier(bean);
  +      }
  +      else
  +      {
  +         throw new IllegalArgumentException("Please use Hibernate as the persistence provider");
  +      }
  +      /*for (Class beanClass=entityClass; beanClass!=Object.class; beanClass=beanClass.getSuperclass() )
  +      {
  +         for (Field field: beanClass.getDeclaredFields()) //TODO: superclasses
  +         {
  +            if ( field.isAnnotationPresent(Id.class) )
  +            {
  +               if ( !field.isAccessible() ) field.setAccessible(true);
  +               return Reflections.get(field, bean);
  +            }
  +         }
  +         for (Method method: beanClass.getDeclaredMethods())
  +         {
  +            if ( method.isAnnotationPresent(Id.class) )
  +            {
  +               if ( !method.isAccessible() ) method.setAccessible(true);
  +               return Reflections.invoke(method, bean);
  +            }
  +         }
  +      }
  +      throw new IllegalArgumentException("no id property found for entity class: " + entityClass.getName());*/
  +   }
  +
   }
  
  
  



More information about the jboss-cvs-commits mailing list