本文整理汇总了Java中org.hibernate.cfg.ImprovedNamingStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ImprovedNamingStrategy类的具体用法?Java ImprovedNamingStrategy怎么用?Java ImprovedNamingStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImprovedNamingStrategy类属于org.hibernate.cfg包,在下文中一共展示了ImprovedNamingStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLocalSessionFactoryBeanWithNamingStrategy
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithNamingStrategy() throws Exception {
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
@Override
protected Configuration newConfiguration() {
return new Configuration() {
@Override
public Configuration setNamingStrategy(NamingStrategy namingStrategy) {
throw new IllegalArgumentException(namingStrategy.toString());
}
};
}
};
sfb.setMappingResources(new String[0]);
sfb.setDataSource(new DriverManagerDataSource());
sfb.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);
try {
sfb.afterPropertiesSet();
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
// expected
assertTrue("Correct exception", ex.getMessage().equals(ImprovedNamingStrategy.INSTANCE.toString()));
}
}
示例2: entityManagerFactory
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setPackagesToScan("com.github.kmbulebu.nicknack.server.model");
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
Properties jpaProperties = new Properties();
jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, "true");
jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, ImprovedNamingStrategy.class.getName());
jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, "false");
jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, "update");
entityManagerFactoryBean.setJpaProperties(jpaProperties);
return entityManagerFactoryBean;
}
示例3: main
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
public static void main(String[] args) {
Ejb3Configuration ejb3Cfg = new Ejb3Configuration();
// set propeties (these were set based on the persistence.xml file)
Properties props = new Properties();
props.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
ejb3Cfg.addProperties(props);
ejb3Cfg.setNamingStrategy(ImprovedNamingStrategy.INSTANCE);
// add annotated classes
ejb3Cfg.addAnnotatedClass(EndUser.class);
ejb3Cfg.addAnnotatedClass(Individual.class);
ejb3Cfg.addAnnotatedClass(Location.class);
ejb3Cfg.addAnnotatedClass(SocialGroup.class);
ejb3Cfg.addAnnotatedClass(Visit.class);
Configuration cfg = ejb3Cfg.getHibernateConfiguration();
SchemaExport se = new SchemaExport(cfg).setOutputFile(RESOURCES_PATH + "specialstudy-schema-ddl.sql");
se.execute(false, false, false, true);
}
示例4: buildSessionFactoryFromAnnotations
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
public static SessionFactory buildSessionFactoryFromAnnotations()
{
try
{
sessionFactory = new AnnotationConfiguration()
.setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
.configure("/hib.cfg.xml")
.buildSessionFactory();
return sessionFactory;
}
catch (Throwable ex)
{
throw new ExceptionInInitializerError(ex);
}
}
示例5: main
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
public static void main(String[] args) {
Configuration configuration = new Configuration().configure().setNamingStrategy(new ImprovedNamingStrategy());
EnversSchemaGenerator generator = new EnversSchemaGenerator(configuration);
SchemaExport export = generator.export();
export.setFormat(false);
export.setOutputFile("src/test/resources/data/h2/create-table-new.sql");
export.create(true, false);
}
示例6: main
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
public static void main(String[] args) {
Configuration configuration = new Configuration().configure().setNamingStrategy(new ImprovedNamingStrategy());
EnversSchemaGenerator generator = new EnversSchemaGenerator(configuration);
SchemaExport export = generator.export();
export.setFormat(false);
export.setOutputFile("src/test/resources/h2schma.sql");
export.create(true, false);
}
示例7: improvedNaming_ClassToTableName
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void improvedNaming_ClassToTableName() {
ImprovedNamingStrategy namingStrategy = new ImprovedNamingStrategy();
for (int i = 0; i < classNames.length; i++) {
String tableName = namingStrategy.classToTableName(classNames[i]);
assertThat(tableName).isEqualTo(tableNames[i]);
}
}
示例8: improvedNaming_PropertyToColumnName
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void improvedNaming_PropertyToColumnName() {
ImprovedNamingStrategy namingStrategy = new ImprovedNamingStrategy();
for (int i = 0; i < propertyNames.length; i++) {
final String columnName = namingStrategy.propertyToColumnName(propertyNames[i]);
assertThat(columnName).isEqualTo(columnNames[i]);
}
}
示例9: improvedNaming_ClassToTableName
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void improvedNaming_ClassToTableName() {
ImprovedNamingStrategy improvedNamingStrategy = new ImprovedNamingStrategy();
for (int i = 0; i < classNames.length; i++) {
Assert.assertEquals(tableNames[i],
improvedNamingStrategy.classToTableName(classNames[i]));
}
}
示例10: improvedNaming_PropertyToColumnName
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void improvedNaming_PropertyToColumnName() {
ImprovedNamingStrategy improvedNamingStrategy = new ImprovedNamingStrategy();
for (int i = 0; i < propertyNames.length; i++) {
Assert.assertEquals(columnNames[i],
improvedNamingStrategy.propertyToColumnName(propertyNames[i]));
}
}
示例11: testSuccessGetResultSetStatementImprovedNamingStrategyJava
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void testSuccessGetResultSetStatementImprovedNamingStrategyJava() {
interpretedClass = InterpretedClassFactory.getInterpretedClass(ExampleModel.class);
resultSetStatement = new ResultSetStatement(interpretedClass, new ImprovedNamingStrategy());
assertEquals(Results.resultSetStringImprovedNamingStrategy, resultSetStatement.getStatement());
}
示例12: testSuccessGetResultSetStatementImprovedNamingStrategyClass
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void testSuccessGetResultSetStatementImprovedNamingStrategyClass() {
interpretedClass = InterpretedClassFactory.getInterpretedClass(ExampleModel.class);
resultSetStatement = new ResultSetStatement(interpretedClass, new ImprovedNamingStrategy());
assertEquals(Results.resultSetStringImprovedNamingStrategy, resultSetStatement.getStatement());
}
示例13: testSuccessGetStatementImprovedNamingStrategyJava
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void testSuccessGetStatementImprovedNamingStrategyJava() {
interpretedClass = InterpretedClassFactory.getInterpretedClass(ExampleModel.class);
statement = new UpdateSQLStatement(interpretedClass, new ImprovedNamingStrategy());
assertEquals(Results.updateSQLStatementStringImprovedNamingStrategy, statement.getStatement());
}
示例14: testSuccessGetStatementImprovedNamingStrategyClass
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void testSuccessGetStatementImprovedNamingStrategyClass() {
interpretedClass = InterpretedClassFactory.getInterpretedClass(getJavaClass());
statement = new UpdateSQLStatement(interpretedClass, new ImprovedNamingStrategy());
assertEquals(Results.updateSQLStatementStringImprovedNamingStrategy, statement.getStatement());
}
示例15: testSuccessGetStatementImprovedNamingStrategyJava
import org.hibernate.cfg.ImprovedNamingStrategy; //导入依赖的package包/类
@Test
public void testSuccessGetStatementImprovedNamingStrategyJava() {
interpretedClass = InterpretedClassFactory.getInterpretedClass(ExampleModel.class);
statement = new InsertSQLStatement(interpretedClass, new ImprovedNamingStrategy());
assertEquals(Results.insertSQLStatementStringImprovedNamingStrategy, statement.getStatement());
}