List of usage examples for org.hibernate.cfg DefaultComponentSafeNamingStrategy DefaultComponentSafeNamingStrategy
DefaultComponentSafeNamingStrategy
From source file:org.xchain.framework.hibernate.HibernateLifecycle.java
License:Apache License
/** * Does Hibernate configuration.//from w w w . j ava 2 s . co m * * @param context */ @StartStep(localName = "hibernate-configuration", before = "hibernate") public static void startHibernateConfig(LifecycleContext context) { if (installDefaultConfiguration()) { if (log.isInfoEnabled()) { log.info( "Reading default Hibernate configuration from '/hibernate.cfg.xml' and '/hibernate.properties'."); } // Uses the hibernate annotation configuration, replace with Configuration() if you // don't use annotations or JDK 5.0 Configuration configuration = new AnnotationConfiguration(); ((AnnotationConfiguration) configuration).setNamingStrategy(new DefaultComponentSafeNamingStrategy()); // Read not only hibernate.properties, but also hibernate.cfg.xml configuration.configure(); // set the configuration. HibernateLifecycle.setConfiguration(configuration); // we will need to clean this up after the lifecycle has started. cleanUp = true; } }
From source file:org.xchain.namespaces.hibernate.test.DefaultSessionFactoryLifecycle.java
License:Apache License
@StartStep(localName = "session-factory", before = "{http://www.xchain.org/hibernate}hibernate-configuration") public static void startLifecycle(LifecycleContext context) throws LifecycleException { // get the hibernate lifecycle and create a configuration for AnnotationConfiguration memory1 = new AnnotationConfiguration(); memory1.setNamingStrategy(new DefaultComponentSafeNamingStrategy()); memory1.configure();//from ww w.j a v a 2 s .c o m HibernateLifecycle.setConfiguration(MEMORY1_NAME, memory1); AnnotationConfiguration memory2 = new AnnotationConfiguration(); memory2.setNamingStrategy(new DefaultComponentSafeNamingStrategy()); memory2.configure(); HibernateLifecycle.setConfiguration(MEMORY2_NAME, memory2); }