Author: arminw
Date: Mon May  8 04:01:29 2006
New Revision: 405012

URL: http://svn.apache.org/viewcvs?rev=405012&view=rev
Log:
update javadoc

Modified:
    
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java

Modified: 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java
URL: 
http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java?rev=405012&r1=405011&r2=405012&view=diff
==============================================================================
--- 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java
 (original)
+++ 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java
 Mon May  8 04:01:29 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.broker.util.sequence;
 
-/* Copyright 2003-2005 The Apache Software Foundation
+/* Copyright 2003-2006 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,23 +52,28 @@
  * sequence number, in multi server environments.
  * <br/>
  * <pre>
- * CREATE PROCEDURE ojb_nextval_proc @SEQ_NAME varchar(100)
- *              AS
- *             declare @MAX_KEY BIGINT
- *              -- return an error if sequence does not exist
- *              -- so we will know if someone truncates the table
- *              set @MAX_KEY = 0
- *
- *              UPDATE OJB_NEXTVAL_SEQ
- *              SET    @MAX_KEY = MAX_KEY = MAX_KEY + 1
- *              WHERE  SEQ_NAME = @SEQ_NAME
- *
- *             if @MAX_KEY = 0
- *                     select 1/0
- *             else
- *                     select @MAX_KEY
+ * CREATE PROCEDURE OJB_NEXTVAL_PROC @SEQ_NAME varchar(150)
+ * AS
+ * declare @MAX_KEY BIGINT
  *
- *              RETURN @MAX_KEY
+ * set nocount off
+ *
+ * set @MAX_KEY = 0
+ *
+ * UPDATE OJB_NEXTVAL_SEQ
+ * SET @MAX_KEY = MAX_KEY = MAX_KEY + 1
+ * WHERE SEQ_NAME = @SEQ_NAME
+ *
+ * -- return an error if
+ * -- sequence does not exist
+ * -- so we will know if someone
+ * -- truncates the table
+ * if @MAX_KEY = 0
+ * RAISERROR ('Sequence %s does not exists!', 16, 1, @SEQ_NAME)
+ * else
+ * select @MAX_KEY
+ *
+ * RETURN @MAX_KEY
  * </pre>
  * <br/>
  * It is possible to define a <code>sequence-name</code>
@@ -90,35 +95,26 @@
  *
  * <table cellspacing="2" cellpadding="2" border="3" frame="box">
  * <tr>
- *     <td><strong>Property Key</strong></td>
- *     <td><strong>Property Values</strong></td>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
  * </tr>
  * <tr>
- *     <td>autoNaming</td>
- *     <td>
- *          Default was 'true'. If set 'true' OJB try to build a
- *          sequence name automatic if none found in field-descriptor
- *          and set this generated name as <code>sequence-name</code>
- *          in field-descriptor. If set 'false' OJB throws an exception
- *          if none sequence name was found in field-descriptor.
- *    </td>
+ * <td>autoNaming</td>
+ * <td>
+ * Default was 'true'. If set 'true' OJB try to build a
+ * sequence name automatic if none found in field-descriptor
+ * and set this generated name as <code>sequence-name</code>
+ * in field-descriptor. If set 'false' OJB throws an exception
+ * if none sequence name was found in field-descriptor.
+ * </td>
  * </tr>
  * </table>
- *
- * <p>
+ * <p/>
  * <b>Limitations:</b>
  * <ul>
- *     <li>do not use when other application use the native key generation 
ditto</li>
+ * <li>do not use when other application use the native key generation 
ditto</li>
  * </ul>
- * </p>
- * <br/>
- * <br/>
  *
- * @author Ryan Vanderwerf
- * @author Edson Carlos Ericksson Richter
- * @author Rajeev Kaul
- * @author Thomas Mahler
- * @author Armin Waibel
  * @version $Id$
  */
 public class SequenceManagerStoredProcedureImpl extends AbstractSequenceManager
@@ -131,6 +127,7 @@
 
     /**
      * Constructor
+     *
      * @param broker
      */
     public SequenceManagerStoredProcedureImpl(PersistenceBroker broker)
@@ -140,6 +137,7 @@
 
     /**
      * Insert syntax for our special table
+     *
      * @param sequenceName
      * @param maxKey
      * @return sequence insert statement
@@ -154,6 +152,7 @@
     /**
      * Gets the actual key - will create a new row with the max key of table 
if it
      * does not exist.
+     *
      * @param field
      * @return
      * @throws SequenceManagerException
@@ -184,12 +183,12 @@
                 if 0 was returned we assume that the stored procedure
                 did not work properly.
                 */
-                if (result == 0)
+                if(result == 0)
                 {
                     throw new SequenceManagerException("No incremented value 
retrieved");
                 }
             }
-            catch (Exception e)
+            catch(Exception e)
             {
                 // maybe the sequence was not created
                 log.info("Could not grab next key, message was " + 
e.getMessage() +
@@ -200,7 +199,7 @@
                     long maxKey = 
SequenceManagerHelper.getMaxForExtent(targetBroker, field);
                     createSequence(targetBroker, field, sequenceName, maxKey);
                 }
-                catch (Exception e1)
+                catch(Exception e1)
                 {
                     String eol = SystemUtils.LINE_SEPARATOR;
                     throw new SequenceManagerException(eol + "Could not grab 
next id, failed with " + eol +
@@ -211,7 +210,7 @@
                 {
                     result = buildNextSequence(targetBroker, sequenceName);
                 }
-                catch (Exception e1)
+                catch(Exception e1)
                 {
                     throw new SequenceManagerException("Could not grab next id 
although a sequence seems to exist", e);
                 }
@@ -230,6 +229,7 @@
     /**
      * Calls the stored procedure stored procedure throws an
      * error if it doesn't exist.
+     *
      * @param broker
      * @param sequenceName
      * @return
@@ -251,10 +251,10 @@
         {
             try
             {
-                if (cs != null)
+                if(cs != null)
                     cs.close();
             }
-            catch (SQLException ignore)
+            catch(SQLException ignore)
             {
                 // ignore it
             }
@@ -263,6 +263,7 @@
 
     /**
      * Creates new row in table
+     *
      * @param broker
      * @param field
      * @param sequenceName
@@ -278,19 +279,19 @@
             stmt = 
broker.serviceStatementManager().getGenericStatement(field.getClassDescriptor(),
 Query.NOT_SCROLLABLE);
             stmt.execute(sp_createSequenceQuery(sequenceName, maxKey));
         }
-        catch (Exception e)
+        catch(Exception e)
         {
             log.error(e);
-            throw new SequenceManagerException("Could not create new row in 
"+SEQ_TABLE_NAME+" table - TABLENAME=" +
+            throw new SequenceManagerException("Could not create new row in " 
+ SEQ_TABLE_NAME + " table - TABLENAME=" +
                     sequenceName + " field=" + field.getColumnName(), e);
         }
         finally
         {
             try
             {
-                if (stmt != null) stmt.close();
+                if(stmt != null) stmt.close();
             }
-            catch (SQLException sqle)
+            catch(SQLException sqle)
             {
                 if(log.isDebugEnabled())
                     log.debug("Threw SQLException while in createSequence and 
closing stmt", sqle);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to