最近在看hibernate深入浅出这本书,在看到自定义数据库类型这里,照着例子写了一个email List映射的例子,可是控制台一直报错
Exception in thread "main" org.hibernate.MappingException: Could not determine type for: com.soft.shen.EmailList, for columns: [org.hibernate.mapping.Column(email)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:410)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at com.neusoft.shen.testdemo.UserTypeDemo.main(UserTypeDemo.java:15)
不知道如何解决

解决方案 »

  1.   

    刚刚我在emailList后面加了个implements Serializable
    可是现在又出现了
    org.hibernate.HibernateException: TransactionFactory class not found: net.sf.hibernate.transaction.JDBCTransactionFactory
    at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:41)
    at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:401)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:129)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
    at com.neusoft.shen.testdemo.UserTypeDemo.setUp(UserTypeDemo.java:26)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    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)
      

  2.   

    有没有知道 TransactionFactory class not found: net.sf.hibernate.transaction.JDBCTransactionFactory
    这个是怎么回事呢
      

  3.   

    我大概知道是怎么回事了,是hibernate的版本问题,之前是2 .x transaction的包路径与3.x系列有差距 应该在做hibernate.hbm.xml做相应的调整