1、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(); Sessi
2、on 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
3、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(Log
4、gerFactory.java:242)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
at org.hibernate.cfg.Configuration.
5、r 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(LoggerFactor
6、y.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.
7、udentTest.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.
8、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.
9、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.Bloc
10、kJUnit4ClassRunner.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:1
11、93) 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.ru
12、nners.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(Remo
13、teTestRunner.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
14、) 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 or
15、g.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
at org.hibernate.cfg.Configuration.
16、e.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(A
17、bstractBatcher.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 Oracl
18、eDialect 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(SimpleValu
19、e.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
20、org.hibernate.tool.hbm2ddl.SchemaExport.






