code: private void writeExternalPKey(ObjectOutput out)
                      throws java.io.IOException {
  
          // write the serialized primary key - can't mix eternaized stream
          // and writeObject so convert to bytes...
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ObjectOutputStream pkeyStream = new ObjectOutputStream(baos);
          pkeyStream.writeObject(pkey);
          pkeyStream.flush();
          pkeyStream.close();
          byte[] pkeyBytes = baos.toByteArray();
          out.writeInt(pkeyBytes.length);
          out.write(pkeyBytes);
      }
docs: Private helper method for writeExternal - writes the primary key
  
  @author Adrian Colyer
  @param out java.io.ObjectOutput
  @exception java.io.IOException The exception description.