Project

General

Profile

Download (1.39 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.hibernate;
10

    
11
import java.util.Collection;
12

    
13
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
14
import org.hibernate.LazyInitializationException;
15

    
16
/**
17
 * Helper class to remove null values from collections which are left over artifacts due to
18
 * https://hibernate.atlassian.net/browse/HHH-9751
19
 *
20
 * @author a.kohlbecker
21
 * @since Jun 13, 2016
22
 */
23
public class HHH_9751_Util {
24

    
25
    private static final Logger logger = LogManager.getLogger(HHH_9751_Util.class);
26

    
27
    /**
28
     * @param collection
29
     * @return the number of null values removed from the collection
30
     */
31
    static public int removeAllNull(Collection<?> collection) {
32
        if (true) {
33
            return 0;
34
        }
35
        int cnt = 0;
36
        try {
37

    
38
           if (collection.contains(null)){
39
             while(collection.contains(null)){
40
                    cnt++;
41
                    collection.remove(null);
42
                }
43
            }
44

    
45
        } catch (LazyInitializationException e) {
46
            logger.info("Cannot clean up uninitialized children without a session, skipping.");
47
        }
48
        return cnt ;
49
    }
50
}
(5-5/13)