I want to use hibernate’s TableGenerator for custom key generation
final SessionImpl session = ((SessionImpl) EntityManagerUtils
.getEntityManager("CORE").getDelegate());
TableGenerator generator = new TableGenerator();
Properties params = new Properties(??????????);
// params.put("identifier_normalizer", ?);
params.put("table_name", "eflow.docs_number_generators");
params.put("value_column_name", "tbl.GENERATOR_VALUE");
params.put("segment_column_name", "tbl.GENERATOR_KEY");
params.put("increment_size", "25");
params.put("segment_value", "2011");
generator.configure(IntegerType.INSTANCE, params, session
.getSessionFactory().getDialect());
Serializable id = generator.generate(session, new Object());
System.out.println(id);
But object with key “identifier_normalizer” is missing and this snippet throws null pointer exception. This object is of type ObjectNameNormalizer which normalizes db object names and is stored in hibernate local mappings.
how to access hibernate’s internal mappings and consequently this ObjectNameNormalizer object ?
Actually as it seems i will need hibernate Mappings object which i don’t know hot to get.
Thanks in advance
Here comes the solution: