该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这个是测试页
public class HibernaTest {
@Test
public void test() {
//1.创建一个SessionFactory 对象
SessionFactory sf = null;
//创建Configuration对象:对应hibernate的基本配置信息和对象关系
Configuration ct = new Configuration().configure();
//创建一个ServiceRegistry 对象:hibernate4.x新添加的对象
//hibernate 的任何配置服务都需要该对象中注册后才能有效
ServiceRegistry serviceRegistry =
new ServiceRegistryBuilder().applySettings(ct.getProperties())
.buildServiceRegistry();
sf = ct.buildSessionFactory(serviceRegistry);
//2.创建一个Session对象
Session session = sf.openSession();
//3.开启事务
Transaction transation = session.beginTransaction();
//4.执行保存操作
News news = new News("java","Leye",new Date(new java.util.Date().getTime()));
session.save(news);
//5.提交事务
transation.commit();
//6.关闭Session
session.close();
//7.关闭SessionFactory 对象
sf.close();
}
}
这是给的提示信息
2015-11-10 0:22:41 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
2015-11-10 0:22:41 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.4.Final}
2015-11-10 0:22:41 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
2015-11-10 0:22:41 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2015-11-10 0:22:41 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2015-11-10 0:22:41 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2015-11-10 0:22:41 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2015-11-10 0:22:41 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/Leye/hibernate/News.hbm.xml
2015-11-10 0:22:41 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2015-11-10 0:22:41 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
2015-11-10 0:22:41 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
2015-11-10 0:22:41 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
2015-11-10 0:22:41 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
2015-11-10 0:22:41 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/test]
2015-11-10 0:22:41 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}
2015-11-10 0:22:41 org.hibernate.dialect.Dialect
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLMyISAMDialect
2015-11-10 0:22:41 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2015-11-10 0:22:41 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2015-11-10 0:22:41 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
INFO: HHH000397: Using ASTQueryTranslatorFactory
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000228: Running hbm2ddl schema update
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000102: Fetching database metadata
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000396: Updating schema
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: NEWS
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: NEWS
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: NEWS
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: create table NEWS (ID integer not null auto_increment, TITLE varchar(255), AUTHOR varchar(255), DATE date, primary key (ID)) type=MyISAM
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=MyISAM' at line 7
2015-11-10 0:22:41 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
Hibernate:
insert
into
NEWS
(TITLE, AUTHOR, DATE)
values
(?, ?, ?)
2015-11-10 0:22:42 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1146, SQLState: 42S02
2015-11-10 0:22:42 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Table 'test.news' doesn't exist
不知道是什么意思,还有最后为什么说没有这个表呢?应该是自动创建的啊...求大神指教