Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 2379169

Browse files
committed
[hibernate] Add Custom Naming strategy
1 parent 05cd3ce commit 2379169

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

grails-app/conf/DataSource.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ hibernate {
88
cache.use_second_level_cache = true
99
cache.use_query_cache = true
1010
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
11+
naming_strategy = net.isammoc.gbj.util.MyNamingStrategy
1112
}
1213
// environment specific settings
1314
environments {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.isammoc.gbj.util
2+
3+
import org.hibernate.cfg.ImprovedNamingStrategy
4+
import org.hibernate.util.StringHelper
5+
6+
class MyNamingStrategy extends ImprovedNamingStrategy {
7+
String classToTableName(String className)
8+
{
9+
"gbj_" + addUnderscores(StringHelper.unqualify(className));
10+
}
11+
12+
String propertyToColumnName(String propertyName) {
13+
"col_" + addUnderscores(StringHelper.unqualify(propertyName));
14+
}
15+
}

0 commit comments

Comments
 (0)