Index: /trunk/lib/Data/ObjectDriver/Driver/DBI.pm
===================================================================
--- /trunk/lib/Data/ObjectDriver/Driver/DBI.pm (revision 6)
+++ /trunk/lib/Data/ObjectDriver/Driver/DBI.pm (revision 7)
@@ -286,5 +286,5 @@
     ## newly-assigned ID.
     unless ($obj->has_primary_key) {
-        $obj->id($driver->fetch_id($sth));
+        $obj->id($driver->fetch_id($dbh, $sth));
     }
     1;
Index: /trunk/lib/Data/ObjectDriver/Driver/DBI/mysql.pm
===================================================================
--- /trunk/lib/Data/ObjectDriver/Driver/DBI/mysql.pm (revision 6)
+++ /trunk/lib/Data/ObjectDriver/Driver/DBI/mysql.pm (revision 7)
@@ -7,5 +7,5 @@
 use Carp qw( croak );
 
-sub fetch_id { $_[1]->{mysql_insertid} || $_[1]->{insertid} }
+sub fetch_id { $_[2]->{mysql_insertid} || $_[2]->{insertid} }
 
 sub commit   { 1 }
Index: /trunk/lib/Data/ObjectDriver/Driver/DBI/Pg.pm
===================================================================
--- /trunk/lib/Data/ObjectDriver/Driver/DBI/Pg.pm (revision 6)
+++ /trunk/lib/Data/ObjectDriver/Driver/DBI/Pg.pm (revision 7)
@@ -24,19 +24,11 @@
     my($class) = @_;
     return join '_', $class->datasource, 'seq';
-} 
+}
 
-sub generate_id {
+sub fetch_id {
     my $driver = shift;
-    my($class) = @_;
-    my $seq = $driver->sequence_name($class);
-    my $dbh = $driver->rw_handle($class->properties->{db});
-    my $sth = $dbh->prepare("SELECT NEXTVAL('$seq')")
-        or return $driver->error($dbh->errstr);
-    $sth->execute
-        or return $driver->error($dbh->errstr);
-    $sth->bind_columns(undef, \my($id));
-    $sth->fetch;
-    $sth->finish;
-    $id;
+    my($dbh, $sth) = @_;
+    $dbh->last_insert_id(undef, undef, undef, undef,
+        { sequence => $driver->sequence_name });
 }
 
