jon 01/10/05 11:54:45
Modified: src/java/org/apache/torque/util BasePeer.java
Log:
more error checking
use the stored variable instead of using the get method each time
Revision Changes Path
1.8 +13 -6
jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java
Index: BasePeer.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BasePeer.java 2001/09/19 22:25:32 1.7
+++ BasePeer.java 2001/10/05 18:54:45 1.8
@@ -110,7 +110,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Frank Y. Kim</a>
* @author <a href="mailto:[EMAIL PROTECTED]">John D. McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Brett McLaughlin</a>
- * @version $Id: BasePeer.java,v 1.7 2001/09/19 22:25:32 jon Exp $
+ * @version $Id: BasePeer.java,v 1.8 2001/10/05 18:54:45 jon Exp $
*/
public abstract class BasePeer implements java.io.Serializable
{
@@ -757,13 +757,20 @@
}
else
{
- throw new Exception("Database insert attempted without anything
specified to insert");
+ throw new Exception("Database insert attempted without " +
+ "anything specified to insert");
}
DatabaseMap dbMap = Torque.getDatabaseMap( criteria.getDbName() );
TableMap tableMap = dbMap.getTable(tableName);
Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
IdGenerator keyGen = tableMap.getIdGenerator();
+ if (keyGen == null)
+ {
+ throw new Exception ("IdGenerator for: '" + tableName +
+ "' is null.");
+ }
+
ColumnMap pk = getPrimaryKey(criteria);
// only get a new key value if you need to
// the reason is that a primary key might be defined
@@ -781,12 +788,12 @@
{
if ( pk.getType() instanceof Number )
{
- id = new NumberKey( tableMap.getIdGenerator()
+ id = new NumberKey( keyGen
.getIdAsBigDecimal(dbCon.getConnection(), keyInfo) );
}
else
{
- id = new StringKey( tableMap.getIdGenerator()
+ id = new StringKey( keyGen
.getIdAsString(dbCon.getConnection(), keyInfo) );
}
criteria.add( pk.getFullyQualifiedName(), id );
@@ -812,12 +819,12 @@
{
if ( pk.getType() instanceof Number )
{
- id = new NumberKey( tableMap.getIdGenerator()
+ id = new NumberKey( keyGen
.getIdAsBigDecimal(dbCon.getConnection(), keyInfo) );
}
else
{
- id = new StringKey( tableMap.getIdGenerator()
+ id = new StringKey( keyGen
.getIdAsString(dbCon.getConnection(), keyInfo) );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]