Skip to main content
summaryrefslogtreecommitdiffstats
blob: 009eb17b6091da3e28fd2d425a3d40499ac282c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.eclipse.emf.cdo.tests.hibernate;

import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.IRepository.Props;
import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil;
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
import org.eclipse.emf.cdo.server.hibernate.teneo.TeneoUtil;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;

import org.eclipse.net4j.util.WrappedException;

import java.util.Map;
import java.util.Properties;

/**
 * @author Eike Stepper
 */
public class HibernateConfig extends RepositoryConfig
{
  public static final HibernateConfig INSTANCE = new HibernateConfig();

  public static final String MAPPING_FILE = "mappingfile";

  private static final long serialVersionUID = 1L;

  public HibernateConfig()
  {
    super("Hibernate");
  }

  @Override
  protected void initRepositoryProperties(Map<String, String> props)
  {
    super.initRepositoryProperties(props);
    props.put(Props.SUPPORTING_AUDITS, "false");
    props.put(Props.VERIFYING_REVISIONS, "false");

    try
    {
      final Properties teneoProperties = new Properties();
      teneoProperties.load(getClass().getResourceAsStream("/app.properties"));
      for (Object key : teneoProperties.keySet())
      {
        props.put((String)key, teneoProperties.getProperty((String)key));
      }
    }
    catch (Exception e)
    {
      throw WrappedException.wrap(e);
    }
  }

  @Override
  protected IStore createStore()
  {
    IHibernateMappingProvider mappingProvider = TeneoUtil.createMappingProvider();
    return CDOHibernateUtil.createStore(mappingProvider);
  }
}

Back to the top