时间:2021-07-01 10:21:17 帮助过:69人阅读
package entity;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
public class TestStudents {
@Test
public void testSchemaExport()
{
//创建配置对象
Configuration config = new Configuration().configure();
//创建服务注册对象
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
//创建sessionFactory
SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry);
//创建session对象
Session session = sessionFactory.getCurrentSession();
//创建SchemaExport对象
SchemaExport export = new SchemaExport(config);
export.create(true, true);
}
}
九月 20, 2015 2:40:45 上午 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
九月 20, 2015 2:40:46 上午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.4.Final}
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: entity/Students.hbm.xml
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: entity/Users.hbm.xml
九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///test?useUnicode=true&characterEncoding=UTF-8]
九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}
九月 20, 2015 2:40:46 上午 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000342: Could not obtain connection to query metadata : Access denied for user 'root'@'localhost' (using password: NO)
九月 20, 2015 2:40:46 上午 org.hibernate.dialect.Dialect
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
九月 20, 2015 2:40:46 上午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
九月 20, 2015 2:40:46 上午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
九月 20, 2015 2:40:46 上午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
INFO: HHH000397: Using ASTQueryTranslatorFactory