Package org.jboss.ejb.plugins.cmp.jdbc.metadata

Examples of org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCAutomaticQueryMetaData


            JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method);
            JDBCReadAheadMetaData readAhead = (findByPKMD == null ?
               entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead());

            // got it add it to known finders
            JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                  method,
                  readAhead,
               entity.getMetaData().getQLCompiler(),
               false
            );
            knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));

            if(log.isDebugEnabled())
               log.debug("Added findByPrimaryKey query command for home interface");
         } catch(NoSuchMethodException e)
         {
            throw new DeploymentException("Home interface does not have a findByPrimaryKey method");
         }
      }

      if(localHomeClass != null)
      {

         Method method;
         try
         {
            // try to get the finder method on the local home interface
            method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() });
         } catch(NoSuchMethodException e)
         {
            throw new DeploymentException("Local home interface does " +
                  "not have the method findByPrimaryKey(" +
                  entity.getPrimaryKeyClass().getName() + ")");
         }

         // got it add it to known finders
         JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method);
         JDBCReadAheadMetaData readAhead = (findByPKMD == null ?
            entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead());
         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
         knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));

         if(log.isDebugEnabled())
            log.debug("Added findByPrimaryKey query command for local home interface");
      }

      //
      // Custom finders - Overrides defined and automatic finders.
      //
      Class ejbClass = manager.getMetaData().getEntityClass();

      Method[] customMethods = ejbClass.getMethods();
      for (int i = 0; i < customMethods.length; i++)
      {
         Method m = customMethods[i];
         String  methodName = m.getName();
         if(methodName.startsWith(EJB_FIND))
         {
            String interfaceName = 'f' +  methodName.substring(4);

            if(homeClass != null)
            {
               try
               {
                  // try to get the finder method on the home interface
                  Method interfaceMethod = homeClass.getMethod(
                        interfaceName,
                        m.getParameterTypes());

                  // got it add it to known finders
                  knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m));

                  if(log.isDebugEnabled())
                     log.debug("Added custom finder " + methodName + " on home interface");
               } catch(NoSuchMethodException e)
               {
                  // this is ok method may not be defined on this interface
               }
            }

            if(localHomeClass != null)
            {
               try
               {
                  // try to get the finder method on the local home interface
                  Method interfaceMethod = localHomeClass.getMethod(
                        interfaceName,
                        m.getParameterTypes());

                  // got it add it to known finders
                  knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m));

                  if(log.isDebugEnabled())
                     log.debug("Added custom finder " + methodName + " on local home interface");
               } catch(NoSuchMethodException e)
               {
                  // this is ok method may not be defined on this interface
               }
            }
         }
      }

      //
      // Defined finders - Overrides automatic finders.
      //
      Iterator definedFinders = manager.getMetaData().getQueries().iterator();
      while(definedFinders.hasNext())
      {
         JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next();

         if(!knownQueries.containsKey(q.getMethod()) )
         {
            if(q instanceof JDBCJBossQLQueryMetaData)
            {
               knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q));

            } else if(q instanceof JDBCDynamicQLQueryMetaData)
            {
               knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q));

            } else if(q instanceof JDBCDeclaredQueryMetaData)
            {
               knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q));

            } else if(q instanceof JDBCQlQueryMetaData)
            {
               knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q));
            }
         }
      }

      //
View Full Code Here


         if(!knownQueries.containsKey(method))
         {
            String name = method.getName();
            if(name.equals(FIND_ALL))
            {
               JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                     method,
                     entity.getMetaData().getReadAhead(),
                  entity.getMetaData().getQLCompiler(), false
                  );
               knownQueries.put(method, factory.createFindAllQuery(q));
            }
            else if(name.startsWith(FIND_BY) && !name.equals(FIND_BY_PK))
            {
               try
               {
                  JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(
                        method,
                        entity.getMetaData().getReadAhead(),
                     entity.getMetaData().getQLCompiler(), false);
                  knownQueries.put(method, factory.createFindByQuery(q));
               } catch (IllegalArgumentException e)
View Full Code Here

/* 157 */         Method method = homeClass.getMethod("findByPrimaryKey", new Class[] { entity.getPrimaryKeyClass() });
/*     */
/* 159 */         JDBCQueryMetaData findByPKMD = this.manager.getMetaData().getQueryMetaDataForMethod(method);
/* 160 */         JDBCReadAheadMetaData readAhead = findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead();
/*     */
/* 164 */         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
/*     */
/* 170 */         this.knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));
/*     */
/* 172 */         if (log.isDebugEnabled())
/* 173 */           log.debug("Added findByPrimaryKey query command for home interface");
/*     */       }
/*     */       catch (NoSuchMethodException e) {
/* 176 */         throw new DeploymentException("Home interface does not have a findByPrimaryKey method");
/*     */       }
/*     */     }
/*     */
/* 180 */     if (localHomeClass != null)
/*     */     {
/*     */       Method method;
/*     */       try
/*     */       {
/* 187 */         method = localHomeClass.getMethod("findByPrimaryKey", new Class[] { entity.getPrimaryKeyClass() });
/*     */       }
/*     */       catch (NoSuchMethodException e) {
/* 190 */         throw new DeploymentException("Local home interface does not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")");
/*     */       }
/*     */
/* 196 */       JDBCQueryMetaData findByPKMD = this.manager.getMetaData().getQueryMetaDataForMethod(method);
/* 197 */       JDBCReadAheadMetaData readAhead = findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead();
/*     */
/* 199 */       JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false);
/* 200 */       this.knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q));
/*     */
/* 202 */       if (log.isDebugEnabled()) {
/* 203 */         log.debug("Added findByPrimaryKey query command for local home interface");
/*     */       }
/*     */
/*     */     }
/*     */
/* 209 */     Class ejbClass = this.manager.getMetaData().getEntityClass();
/*     */
/* 211 */     Method[] customMethods = ejbClass.getMethods();
/* 212 */     for (int i = 0; i < customMethods.length; i++)
/*     */     {
/* 214 */       Method m = customMethods[i];
/* 215 */       String methodName = m.getName();
/* 216 */       if (!methodName.startsWith("ejbFind"))
/*     */         continue;
/* 218 */       String interfaceName = 'f' + methodName.substring(4);
/*     */
/* 220 */       if (homeClass != null)
/*     */       {
/*     */         try
/*     */         {
/* 225 */           Method interfaceMethod = homeClass.getMethod(interfaceName, m.getParameterTypes());
/*     */
/* 230 */           this.knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(this.manager, m));
/*     */
/* 232 */           if (log.isDebugEnabled()) {
/* 233 */             log.debug("Added custom finder " + methodName + " on home interface");
/*     */           }
/*     */         }
/*     */         catch (NoSuchMethodException e)
/*     */         {
/*     */         }
/*     */       }
/* 240 */       if (localHomeClass == null) {
/*     */         continue;
/*     */       }
/*     */       try
/*     */       {
/* 245 */         Method interfaceMethod = localHomeClass.getMethod(interfaceName, m.getParameterTypes());
/*     */
/* 250 */         this.knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(this.manager, m));
/*     */
/* 252 */         if (log.isDebugEnabled()) {
/* 253 */           log.debug("Added custom finder " + methodName + " on local home interface");
/*     */         }
/*     */
/*     */       }
/*     */       catch (NoSuchMethodException e)
/*     */       {
/*     */       }
/*     */
/*     */     }
/*     */
/* 265 */     Iterator definedFinders = this.manager.getMetaData().getQueries().iterator();
/* 266 */     while (definedFinders.hasNext())
/*     */     {
/* 268 */       JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next();
/*     */
/* 270 */       if (!this.knownQueries.containsKey(q.getMethod()))
/*     */       {
/* 272 */         if ((q instanceof JDBCJBossQLQueryMetaData))
/*     */         {
/* 274 */           this.knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q));
/*     */         }
/* 276 */         else if ((q instanceof JDBCDynamicQLQueryMetaData))
/*     */         {
/* 278 */           this.knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q));
/*     */         }
/* 280 */         else if ((q instanceof JDBCDeclaredQueryMetaData))
/*     */         {
/* 282 */           this.knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q));
/*     */         }
/* 284 */         else if ((q instanceof JDBCQlQueryMetaData))
/*     */         {
/* 286 */           this.knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q));
/*     */         }
/*     */
/*     */       }
/*     */
/*     */     }
View Full Code Here

/* 322 */       if (this.knownQueries.containsKey(method))
/*     */         continue;
/* 324 */       String name = method.getName();
/* 325 */       if (name.equals("findAll"))
/*     */       {
/* 327 */         JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false);
/*     */
/* 332 */         this.knownQueries.put(method, factory.createFindAllQuery(q));
/*     */       } else {
/* 334 */         if ((!name.startsWith("findBy")) || (name.equals("findByPrimaryKey")))
/*     */           continue;
/*     */         try
/*     */         {
/* 338 */           JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false);
/*     */
/* 342 */           this.knownQueries.put(method, factory.createFindByQuery(q));
/*     */         }
/*     */         catch (IllegalArgumentException e) {
/* 345 */           log.debug("Could not create the finder " + name + ", because no matching CMP field was found.");
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCAutomaticQueryMetaData

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.