Skip to contentPackage: PersistenceUtil
PersistenceUtil
Coverage
1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model;
16:
17: /**
18: * Utility interface between the application and the persistence provider(s).
19: * <p>
20: * The {@code PersistenceUtil} interface instance obtained from the {@link cz.cvut.kbss.jopa.Persistence} class is used
21: * to determine the load state of an entity or entity attribute regardless of which persistence provider in the
22: * environment created the entity.
23: */
24: public interface PersistenceUtil {
25:
26: /**
27: * Determine the load state of a given persistent attribute.
28: *
29: * @param entity entity containing the attribute
30: * @param attributeName name of attribute whose load state is to be determined
31: * @return {@code false} if entity's state has not been loaded or if the attribute state has not been loaded, else
32: * {@code true}
33: */
34: boolean isLoaded(Object entity, String attributeName);
35:
36: /**
37: * Determine the load state of an entity. This method can be used to determine the load state of an entity passed as
38: * a reference. An entity is considered loaded if all attributes for which {@link
39: * cz.cvut.kbss.jopa.model.annotations.FetchType#EAGER} has been specified have been loaded.
40: * <p>
41: * The {@link #isLoaded(Object, String)} method should be used to determine the load state of an attribute. Not
42: * doing so might lead to unintended loading of state.
43: *
44: * @param entity whose load state is to be determined
45: * @return {@code false} if the entity has not been loaded, else {@code true}
46: */
47: boolean isLoaded(Object entity);
48: }