Java源码示例:org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
示例1
public static void main(String[] args) {
/*Configuration configuration = new Configuration();
configuration.configure("hibernate.cfg.xml");
configuration.setProperty("hibernate.connection.username","grafana123");
ServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).configure().build();*/
ServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build();
MetadataSources sources = new MetadataSources( standardRegistry );
sources.addAnnotatedClass( Test.class );
Metadata metadata = sources.getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE).build();
SessionFactory sessionFactory = metadata.buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Test s = new Test();
s.setName("12Vishal123");
session.save(s);
session.getTransaction().commit();
session.close();
sessionFactory.close();
}
示例2
private Metadata init(Properties dbConfig) {
StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.applySettings(dbConfig)
.build();
return new MetadataSources(registry)
.addAnnotatedClass(CWLMainProcessRecord.class)
.addAnnotatedClass(CWLStepProcessRecord.class)
.getMetadataBuilder()
.applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE)
.build();
}
示例3
private static void addImplicitNamingStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"default",
ImplicitNamingStrategyJpaCompliantImpl.class);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"jpa",
ImplicitNamingStrategyJpaCompliantImpl.class);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"component-path",
ImplicitNamingStrategyComponentPathImpl.class);
}
示例4
protected void reset() {
implicitNamingStrategy = ImplicitNamingStrategyJpaCompliantImpl.INSTANCE;
physicalNamingStrategy = PhysicalNamingStrategyStandardImpl.INSTANCE;
namedQueries = new HashMap<String,NamedQueryDefinition>();
namedSqlQueries = new HashMap<String,NamedSQLQueryDefinition>();
sqlResultSetMappings = new HashMap<String, ResultSetMappingDefinition>();
namedEntityGraphMap = new HashMap<String, NamedEntityGraphDefinition>();
namedProcedureCallMap = new HashMap<String, NamedProcedureCallDefinition>( );
standardServiceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry );
entityTuplizerFactory = new EntityTuplizerFactory();
interceptor = EmptyInterceptor.INSTANCE;
properties = new Properties( );
properties.putAll( standardServiceRegistryBuilder.getSettings());
}
示例5
private void addImplicitNamingStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"default",
ImplicitNamingStrategyJpaCompliantImpl.class
);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"jpa",
ImplicitNamingStrategyJpaCompliantImpl.class
);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"legacy-jpa",
ImplicitNamingStrategyLegacyJpaImpl.class
);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"legacy-hbm",
ImplicitNamingStrategyLegacyHbmImpl.class
);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"component-path",
ImplicitNamingStrategyComponentPathImpl.class
);
}