protected < T > int store ( final Table < T > table , final T object ) throws PersistenceException { return executeUpdate ( new Operation < Integer > ( ) { public Integer invoke ( Connection conn , DatabaseLiaison liaison ) throws SQLException , PersistenceException { if ( table . update ( conn , object ) == 0 ) { table . insert ( conn , object ) ; return liaison . lastInsertedId ( conn , null , table . getName ( ) , "TODO" ) ; } return - 1 ; } } ) ; }
First attempts to update the supplied object and if that modifies zero rows inserts the object into the specified table . The table must be configured to store items of the supplied type .