org.hibernate.MappingException: Could not determine type for: java.long.String, at table: STUDENTS,

 

学习笔记

在整合hibernate4后,去写一个测试出现了这个错误

org.hibernate.MappingException: Could not determine type for: java.long.String, at table: STUDENTS, for columns: [org.hibernate.mapping.Column(sname)]
 at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:349)
 at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:322)
 at org.hibernate.mapping.Property.isValid(Property.java:241)
 at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:496)
 at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
 at org.hibernate.cfg.Configuration.validate(Configuration.java:1360)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1851)
 at entity.TestStudents.testSchemaExport(TestStudents.java:23)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497)
 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.ParentRunner.runLeaf(ParentRunner.java:263)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

 

org.hibernate.MappingException: Could not determine type for: java.long.String, at table: STUDENTS,_第1张图片

org.hibernate.MappingException: Could not determine type for: java.long.String, at table: STUDENTS,_第2张图片

查找后知道String属于Java中的规范,而在hibernate配置中需要写小写string。所以我把Java.long.String都替换成小写string。

 

再次测试便成功运行了。如果测试过程中有这种情况异常java.lang.NoClassDefFoundError:javax transaction SystemException

很有可能缺少jta.jar包.导入后,在测试就行了。

org.hibernate.MappingException: Could not determine type for: java.long.String, at table: STUDENTS,_第3张图片

 

你可能感兴趣的:(Java,SSH框架)