本文主要是介绍org.hibernate.MappingException: Could not determine type for: String 数据类型错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
用Hibernate连接数据库时出现了如下错误:org.hibernate.MappingException: Could not determine type for: String, at table: labuser, for columns: [org.hibernate.mapping.Column(userid)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:307)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at com.guet.orm.dao.AnimalDao.insertAnimals(AnimalDao.java:33)
at com.guet.orm.test.HibernateDaoTest.insertTiger(HibernateDaoTest.java:43)
at com.guet.orm.test.HibernateDaoTest.main(HibernateDaoTest.java:29)
根据错误提示找到对应的配置文件,最终发现错误根源在
<discriminator column="userid" type="String"/>。
"String"是java的数据类型,Hibernate中对应的数据类型是"string",
在书写hibernate的配置文件时,要么使用"string",要么使用"java.lang.String"。
这篇关于org.hibernate.MappingException: Could not determine type for: String 数据类型错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!