Unbork handling of objects with no primary key. Added a comment indicating

where we will need to cache the results of a modifier (like an insert or an
update). Added hasPrimaryKey() to DepotMarshaller which we will soon use
externally.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1927 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2006-09-26 19:41:40 +00:00
parent f0a8a76238
commit eaa520044b
2 changed files with 14 additions and 4 deletions
@@ -173,6 +173,14 @@ public class DepotMarshaller<T>
return _tableName;
}
/**
* Returns true if our persistent object defines a primary key.
*/
public boolean hasPrimaryKey ()
{
return (_primaryKey != null);
}
/**
* Returns a key configured with the primary key of the supplied object.
* Throws an exception if the persistent object did not declare a primary
@@ -180,7 +188,7 @@ public class DepotMarshaller<T>
*/
public DepotRepository.Key getPrimaryKey (Object object)
{
if (_primaryKey == null) {
if (!hasPrimaryKey()) {
throw new UnsupportedOperationException(
getClass().getName() + " does not define a primary key");
}
@@ -338,7 +346,7 @@ public class DepotMarshaller<T>
throws SQLException
{
// if we have no primary key or no generator, then we're done
if (_primaryKey == null || _keyGenerator == null) {
if (!hasPrimaryKey() || _keyGenerator == null) {
return;
}