2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.persistence
.hibernate
;
11 import java
.io
.Serializable
;
13 import org
.hibernate
.cache
.internal
.NoCachingRegionFactory
;
14 import org
.hibernate
.cache
.spi
.RegionFactory
;
15 import org
.hibernate
.envers
.boot
.internal
.EnversIntegrator
;
22 public class HibernateConfiguration
implements Serializable
{
24 private static final long serialVersionUID
= -894395918847594447L;
26 public final static String SHOW_SQL
= "hibernate.show_sql";
28 public final static String FORMAT_SQL
= "hibernate.format_sql";
30 public final static String REGISTER_SEARCH
= "hibernate.search.autoregister_listeners";
32 public final static String REGISTER_ENVERS
= EnversIntegrator
.AUTO_REGISTER
;
34 public final static String CACHE_PROVIDER_CLASS
= "hibernate.cache.region.factory_class";
37 public static final boolean SHOW_SQL_DEFAULT
= false;
38 public static final boolean FORMAT_SQL_DEFAULT
= false;
39 public static final boolean REGISTER_SEARCH_DEFAULT
= false;
40 public static final boolean REGISTER_ENVERS_DEFAULT
= true;
42 public static final Class
<?
extends RegionFactory
> CACHE_PROVIDER_DEFAULT
= NoCachingRegionFactory
.class;
47 public static HibernateConfiguration
NewDefaultInstance() {
48 HibernateConfiguration result
= NewInstance(SHOW_SQL_DEFAULT
, FORMAT_SQL_DEFAULT
,
49 REGISTER_SEARCH_DEFAULT
, REGISTER_ENVERS_DEFAULT
, CACHE_PROVIDER_DEFAULT
);
53 public static HibernateConfiguration
NewInstance(Boolean showSql
, Boolean formatSql
,
54 Boolean registerSearch
, Boolean registerEnvers
,
55 Class
<?
extends RegionFactory
> cacheProviderClass
) {
56 HibernateConfiguration result
= new HibernateConfiguration();
57 result
.setShowSql(showSql
);
58 result
.setFormatSql(formatSql
);
59 result
.setRegisterSearch(registerSearch
);
60 result
.setRegisterEnvers(registerEnvers
);
61 result
.setCacheProviderClass(cacheProviderClass
);
66 private Boolean showSql
= null;
68 private Boolean formatSql
= null;
70 private Boolean registerSearch
= null;
72 private Boolean registerEnvers
= null;
74 private Class
<?
extends RegionFactory
> cacheProviderClass
= null;
76 // *********** GETTERS /SETTERS ****************************/
78 public Boolean
getShowSql() {
81 public boolean getShowSql(boolean defaultValue
) {
82 return showSql
!= null ? showSql
: defaultValue
;
84 public void setShowSql(Boolean showSql
) {
85 this.showSql
= showSql
;
88 public Boolean
getFormatSql() {
91 public boolean getFormatSql(boolean defaultValue
) {
92 return formatSql
!= null ? formatSql
: defaultValue
;
94 public void setFormatSql(Boolean formatSql
) {
95 this.formatSql
= formatSql
;
98 public Boolean
getRegisterSearch() {
99 return registerSearch
;
101 public boolean getRegisterSearch(boolean defaultValue
) {
102 return registerSearch
!= null ? registerSearch
: defaultValue
;
104 public void setRegisterSearch(Boolean registerSearch
) {
105 this.registerSearch
= registerSearch
;
108 public Boolean
getRegisterEnvers() {
109 return registerEnvers
;
111 public boolean getRegisterEnvers(boolean defaultValue
) {
112 return registerEnvers
!= null ? registerEnvers
: defaultValue
;
114 public void setRegisterEnvers(Boolean registerEnvers
) {
115 this.registerEnvers
= registerEnvers
;
118 public Class
<?
extends RegionFactory
> getCacheProviderClass() {
119 return cacheProviderClass
;
121 public Class
<?
extends RegionFactory
> getCacheProviderClass(Class
<?
extends RegionFactory
> defaultValue
) {
122 return cacheProviderClass
!= null ? cacheProviderClass
: defaultValue
;
124 public void setCacheProviderClass(Class
<?
extends RegionFactory
> cacheProviderClass
) {
125 this.cacheProviderClass
= cacheProviderClass
;
128 // ******************** toString *******************************/
130 public String
toString() {
131 return "HibernateConfiguration [showSql=" + showSql
+ ", formatSql=" + formatSql
+ ", registerSearch="
132 + registerSearch
+ ", registerEnvers=" + registerEnvers
+ ", cacheProviderClass=" + cacheProviderClass