Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persist.hibernate

File HibernateProviderConfigurationSource.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
36% of files have more coverage

Code metrics

4
21
10
1
71
56
12
0.57
2.1
10
1.2

Classes

Class Line # Actions
HibernateProviderConfigurationSource 6 21 12
0.4285714342.9%
 

Contributing tests

This file is covered by 7 tests. .

Source view

1    package io.sunshower.persist.hibernate;
2   
3    import io.sunshower.jpa.configuration.JpaProviderProperties;
4    import java.util.Properties;
5   
 
6    public class HibernateProviderConfigurationSource implements JpaProviderProperties {
7   
8    private final DataDefinitionLanguage ddl;
9    private final SearchConfiguration search;
10    private final HibernateCacheConfiguration cache;
11    private final HibernateDialectProperties provider;
12   
 
13  4 toggle public HibernateProviderConfigurationSource(
14    final DataDefinitionLanguage ddl,
15    final SearchConfiguration search,
16    final HibernateDialectProperties provider,
17    final HibernateCacheConfiguration cache) {
18  4 this.ddl = ddl;
19  4 this.cache = cache;
20  4 this.search = search;
21  4 this.provider = provider;
22    }
23   
 
24  2 toggle public DataDefinitionLanguage ddl() {
25  2 return ddl;
26    }
27   
 
28  2 toggle public HibernateCacheConfiguration cache() {
29  2 return cache;
30    }
31   
 
32  1 toggle public HibernateDialectProperties getProvider() {
33  1 return provider;
34    }
35   
 
36  2 toggle public SearchConfiguration getSearch() {
37  2 return search;
38    }
39   
 
40  4 toggle public HibernateCacheConfiguration getCache() {
41  4 return cache;
42    }
43   
 
44  0 toggle public Properties toNative() {
45  0 final Properties properties = new Properties();
46  0 configureSearch(properties);
47   
48  0 configureDialect(properties);
49  0 configureDiagnostics(properties);
50   
51  0 return properties;
52    }
53   
 
54  0 toggle private void configureDialect(Properties properties) {
55  0 properties.put("jpa.dialect", provider.dialect());
56    }
57   
 
58  0 toggle private void configureDiagnostics(Properties properties) {
59  0 properties.setProperty("hibernate.show_sql", Boolean.toString(ddl.showSql()));
60  0 properties.setProperty("hibernate.format_sql", Boolean.toString(ddl.formatSql()));
61  0 if (ddl.generate()) {
62  0 properties.setProperty("hibernate.hbm2ddl.auto", ddl.strategy());
63    }
64    }
65   
 
66  0 toggle private void configureSearch(Properties properties) {
67  0 if (search != null) {
68  0 properties.setProperty(search.type(), search.value());
69    }
70    }
71    }