Merge branch 'release/5.45.0'
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / initializer / GatheringEventLocationAutoInitializer.java
1 /**
2 * Copyright (C) 2009 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.persistence.dao.initializer;
10
11 import java.util.Optional;
12
13 import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
14
15 /**
16 * @author a.kohlbecker
17 * @since 30.07.2010
18 *
19 * @TODO only necessary since Point is not subclass of CdmBase
20 */
21 public class GatheringEventLocationAutoInitializer extends AutoPropertyInitializer<GatheringEvent> {
22
23 @Override
24 public void initialize(GatheringEvent bean) {
25 try {
26 beanInitializer.initializeInstance(bean.getExactLocation().getReferenceSystem().getRepresentations());
27 } catch (NullPointerException npe){
28 /* IGNORE */
29 }
30 }
31
32 @Override
33 public Optional<String> hibernateFetchJoin(Class<?> clazz, String beanAlias){
34 return Optional.of(String.format(" LEFT JOIN FETCH %s.exactLocation l LEFT JOIN l.referenceSystem rs LEFT JOIN rs.representations ", beanAlias));
35 }
36
37 }