@@ -0,0 +1,2559 @@
+package org.sagebionetworks.audit;%0A%0Aimport java.io.IOException;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0A%0Aimport javax.annotation.Resource;%0A%0Aimport org.slf4j.Logger;%0Aimport org.springframework.dao.DataAccessException;%0Aimport org.springframework.jdbc.core.ResultSetExtractor;%0Aimport org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;%0A%0Apublic class App %7B%0A%0A    private static String TABLE_NAME = %22TEST%22; // for testing%0A    //private static STring TABLE_NAME = %22ACCESS_REQUIREMENT%22;%0A    private static String ADD_COLUMN = %22ALTER TABLE %22 + TABLE_NAME + %22 ADD COLUMN CONCRETE_TYPE VARCHAR(256);%22;%0A    private static String GET_ALL_ID = %22SELECT ID FROM %22 + TABLE_NAME + %22;%22;%0A    private static String GET_A_BLOB = %22SELECT SERIALIZED_ENTITY FROM %22 + TABLE_NAME + %22 WHERE ID=:id;%22;%0A    private static String UPDATE = %22UPDATE %22 + TABLE_NAME + %22 SET CONCRETE_TYPE=:concreteType WHERE ID=:id;%22;%0A%0A    @Resource%0A    private static NamedParameterJdbcTemplate dbTemplate;%0A%0A    public static void main(String%5B%5D args) %7B%0A        final Logger logger = org.slf4j.LoggerFactory.getLogger(App.class);%0A        int rowAffected = 0;%0A%0A        /* Step 1: Add new column */%0A        try %7B%0A            rowAffected = dbTemplate.update(ADD_COLUMN, new HashMap%3CString, Object%3E());%0A        %7D catch (DataAccessException e) %7B%0A            logger.error(%22Failed to add column.%22, e);%0A        %7D%0A%0A        assert(rowAffected != 0);%0A%0A        /* Step 2: Get all ids */%0A        List%3CLong%3E idList = dbTemplate.queryForList(GET_ALL_ID, new HashMap%3CString, Object%3E(), Long.class);%0A        if (idList != null) %7B%0A            for (Long id : idList) %7B%0A%0A                /* Step 3: Get the Blob */%0A                byte%5B%5D blob = dbTemplate.query(GET_A_BLOB, new ResultSetExtractor%3Cbyte%5B%5D%3E() %7B%0A                    @Override%0A                    public byte%5B%5D extractData(ResultSet rs) throws SQLException, DataAccessException %7B%0A                        if (rs.next()) %7B%0A                            return rs.getBytes(%22SERIALIZED_ENTITY%22);%0A                        %7D else %7B%0A                            return null;%0A                        %7D%0A                    %7D%0A                %7D);%0A%0A                /* Step 4: decompress the blob and print it*/%0A                try %7B%0A                    String text = GzipUtils.decompress(blob);%0A                    System.out.println(text);%0A                %7D catch (IOException e) %7B%0A                    logger.error(%22Failed to decompress a blob.%22, e);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

add the app that does the work