为了账号安全,请及时绑定邮箱和手机立即绑定

静态初始化异常 。 很无奈 下面日志

十二月 22, 2016 9:29:06 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}

十二月 22, 2016 9:29:06 下午 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {4.3.0.Final}

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Configuration configure

INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: com/xn/entity/Grade.hbm.xml

十二月 22, 2016 9:29:06 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: com/xn/entity/Student.hbm.xml

十二月 22, 2016 9:29:06 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

十二月 22, 2016 9:29:06 下午 org.hibernate.cfg.Configuration doConfigure

INFO: HHH000041: Configured SessionFactory: null

十二月 22, 2016 9:29:06 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)

十二月 22, 2016 9:29:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/sgu?useUnicode=true&characterEncoding=utf8]

十二月 22, 2016 9:29:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH000046: Connection properties: {user=root, password=****}

十二月 22, 2016 9:29:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH000006: Autocommit mode: false

十二月 22, 2016 9:29:07 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000115: Hibernate connection pool size: 20 (min=1)

十二月 22, 2016 9:29:07 下午 org.hibernate.dialect.Dialect <init>

INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect

Exception in thread "main" java.lang.ExceptionInInitializerError

at com.xn.entity.test.add(test.java:25)

at com.xn.entity.test.main(test.java:13)

Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/xn/entity/Student.hbm.xml

at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3736)

at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3725)

at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3713)

at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)

at com.xn.util.hibernateUtil.<clinit>(hibernateUtil.java:19)

... 2 more

Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement

at org.hibernate.cfg.HbmBinder.bindColumns(HbmBinder.java:1117)

at org.hibernate.cfg.HbmBinder.bindColumnsOrFormula(HbmBinder.java:1627)

at org.hibernate.cfg.HbmBinder.bindSimpleValue(HbmBinder.java:1193)

at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:443)

at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:386)

at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:326)

at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:177)

at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3733)

... 7 more


正在回答

2 回答

并没发现什么错啊。。

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!-- Generated 2016-12-22 20:01:40 by Hibernate Tools 3.5.0.Final -->

<hibernate-mapping>

    <class name="com.xn.entity.Student" table="student">

        <id name="sid" type="java.lang.Integer" column="sid" >

            <column name="sid" />

            <generator class="increment"></generator>

        </id>

        <property name="sname" type="java.lang.String">

            <column name="sname" />

        </property>

        <property name="sex" type="java.lang.String">

            <column name="sex" />

        </property>

    </class>

</hibernate-mapping>


0 回复 有任何疑惑可以回复我~
#1

慕粉3796571

主键配置错误
2017-06-15 回复 有任何疑惑可以回复我~

恩,Student.hbm.xml这个文件内容有问题,不能解析和映射,

你在Student.hbm.xml文件里里的内容找找看哪里内容写错了

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之一对多映射
  • 参与学习       42171    人
  • 解答问题       295    个

Hibernate中一对多关联映射配置,以及cascade和inverse属性作用

进入课程

静态初始化异常 。 很无奈 下面日志

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信