收藏 分销(赏)

Hibernate学习笔记.doc

上传人:仙人****88 文档编号:8516561 上传时间:2025-02-16 格式:DOC 页数:5 大小:1.13MB 下载积分:10 金币
下载 相关 举报
Hibernate学习笔记.doc_第1页
第1页 / 共5页
Hibernate学习笔记.doc_第2页
第2页 / 共5页


点击查看更多>>
资源描述
Hibernate3.3.2_HelloWorld public class StudentTest { public static void main(String[] args ) { Student s=new Student(); s.setAge(42); s.setId("21"); s.setName("kewweiquan"); Configuration cfg=new Configuration(); SessionFactory sf =cfg.configure().buildSessionFactory(); Session session =sf.openSession(); session.beginTransaction(); session.save(s); session.getTransaction().commit(); session.close(); sf.close(); } } Exception in thread "main" java.lang.ExceptionInInitializerError at com.sky.model.StudentTest.main(StudentTest.java:19) Caused by: java.lang.NullPointerException at org.slf4j.LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152) ... 1 more SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152) at com.sky.model.StudentTest.main(StudentTest.java:19) java.lang.ExceptionInInitializerError at com.tdh.serviceImpl.ReportManagerImpl.add(ReportManagerImpl.java:26) at test.ReportManagerImplTest.testAdd(ReportManagerImplTest.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.NullPointerException at org.slf4j应该是Slf 的jar包问题。 .LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152) ... 25 more org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) 存中文的话就会报错 java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column 警告: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead Exception in thread "main" org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Student, for columns: [org.hibernate.mapping.Column(courses)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292) at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:161) at org.hibernate.mapping.Column.getSqlType(Column.java:205) at org.hibernate.mapping.Table.sqlCreateString(Table.java:420) at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:895) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:129) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91) at com.bjsxt.hibernate.HibernateORMappingTest.beforeClass(HibernateORMappingTest.java:18) at com.bjsxt.hibernate.HibernateORMappingTest.main(HibernateORMappingTest.java:51) 注解主键应该设在getter方法这里 这个问题就解决了!!!
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服