User: mulder  
  Date: 00/10/21 19:05:38

  Modified:    src/main/org/jboss/ejb/plugins/jaws/jdbc
                        JDBCBeanExistsCommand.java
  Log:
  Use column numbers instead of names.
  InterBase can't seem to look up a ResultSet column by name if the name
    is an alias.  Besides, there's only one column in this query!
  
  Revision  Changes    Path
  1.6       +13 -13    
jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCBeanExistsCommand.java
  
  Index: JDBCBeanExistsCommand.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCBeanExistsCommand.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDBCBeanExistsCommand.java        2000/09/29 21:25:20     1.5
  +++ JDBCBeanExistsCommand.java        2000/10/22 02:05:38     1.6
  @@ -19,28 +19,28 @@
    * @see <related>
    * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class JDBCBeanExistsCommand extends JDBCQueryCommand
   {
      // Constructors --------------------------------------------------
  -   
  +
      public JDBCBeanExistsCommand(JDBCCommandFactory factory)
      {
         super(factory, "Exists");
  -      String sql = "SELECT COUNT(*) AS Total FROM " + jawsEntity.getTableName() +
  +      String sql = "SELECT COUNT(*) FROM " + jawsEntity.getTableName() +
                      " WHERE " + getPkColumnWhereList();
         setSQL(sql);
      }
  -   
  +
      // Public --------------------------------------------------------
  -   
  +
      // Checks whether the database already holds the entity
  -   
  +
      public boolean execute(Object id)
      {
         boolean result = false;
  -      
  +
         try
         {
            result = ((Boolean)jdbcExecute(id)).booleanValue();
  @@ -48,25 +48,25 @@
         {
              log.debug(e);
         }
  -      
  +
         return result;
      }
  -   
  +
      // JDBCQueryCommand overrides ------------------------------------
  -   
  -   protected void setParameters(PreparedStatement stmt, Object argOrArgs) 
  +
  +   protected void setParameters(PreparedStatement stmt, Object argOrArgs)
         throws Exception
      {
         setPrimaryKeyParameters(stmt, 1, argOrArgs);
      }
  -   
  +
      protected Object handleResult(ResultSet rs, Object argOrArgs) throws Exception
      {
         if ( !rs.next() )
         {
            throw new SQLException("Unable to check for EJB in database");
         }
  -      int total = rs.getInt("Total");
  +      int total = rs.getInt(1);
         return new Boolean(total >= 1);
      }
   }
  
  
  

Reply via email to