Removed code duplicates and fixed one minor issue
This commit is contained in:
		
							parent
							
								
									b8291be084
								
							
						
					
					
						commit
						e7fd07652e
					
				@ -42,20 +42,15 @@ public class PsqlLatestInsertTsRepository extends AbstractInsertRepository imple
 | 
			
		||||
    private Boolean updateByLatestTs;
 | 
			
		||||
 | 
			
		||||
    private static final String BATCH_UPDATE =
 | 
			
		||||
            "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ?;";
 | 
			
		||||
 | 
			
		||||
            "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ?";
 | 
			
		||||
 | 
			
		||||
    private static final String INSERT_OR_UPDATE =
 | 
			
		||||
            "INSERT INTO ts_kv_latest (entity_id, key, ts, bool_v, str_v, long_v, dbl_v,  json_v) VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json)) " +
 | 
			
		||||
                    "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json);";
 | 
			
		||||
                    "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json)";
 | 
			
		||||
 | 
			
		||||
    private static final String BATCH_UPDATE_BY_LATEST_TS =
 | 
			
		||||
            "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ? AND ts <= ?;";
 | 
			
		||||
    private static final String BATCH_UPDATE_BY_LATEST_TS = BATCH_UPDATE + " AND ts_kv_latest.ts <= ?";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private static final String INSERT_OR_UPDATE_BY_LATEST_TS =
 | 
			
		||||
            "INSERT INTO ts_kv_latest (entity_id, key, ts, bool_v, str_v, long_v, dbl_v,  json_v) VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json)) " +
 | 
			
		||||
                    "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE ts_kv_latest.ts <= ?;";
 | 
			
		||||
    private static final String INSERT_OR_UPDATE_BY_LATEST_TS = INSERT_OR_UPDATE + " WHERE ts_kv_latest.ts <= ?";
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void saveOrUpdate(List<TsKvLatestEntity> entities) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user