Hibernate Ungültige Zuordnung Ausnahme
Ich bin mit der neuesten Gläser für hibernate. (z.B. hibernate-release-4.0.1.Final )
In den vorherigen Versionen war ich immer die korrekte Ausgabe.
Ich ersetzte die hibernate jars und es war eine Ausnahme.
org.hibernate.InvalidMappingException: kann Nicht zum Lesen XML -
Ich lese einige blogs und verändert die doctype-Deklaration
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
Immer noch der Fehler besteht weiterhin.
ich befestige meine cfg.xml und einer meiner hbm.xml (alle 10 cant angebracht werden)
Plez lassen Sie mich, was ist das problem und was soll die Lösung sein.
Danke
Fehler:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.cluster.action.Action.main(Action.java:19)
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:106)
at org.hibernate.cfg.Configuration.add(Configuration.java:474)
at org.hibernate.cfg.Configuration.add(Configuration.java:470)
at org.hibernate.cfg.Configuration.add(Configuration.java:643)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:726)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2102)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2074)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2054)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2007)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1922)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1901)
at com.cluster.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 1 more
Caused by: org.dom4j.DocumentException: Error on line 28 of document : Attribute name "cas" associated with an element type "key" must be followed by the ' = ' character. Nested exception: Attribute name "cas" associated with an element type "key" must be followed by the ' = ' character.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:76)
... 12 more
hibernate.cfg.xml :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">julyaugust</property>
<property name="connection.password">julyaugust</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<mapping resource="com/cluster/entity/employee.hbm.xml"/>
<mapping resource="com/cluster/entity/department.hbm.xml"/>
<mapping resource="com/cluster/entity/addressDetails.hbm.xml"/>
<mapping resource="com/cluster/entity/addressType.hbm.xml"/>
<mapping resource="com/cluster/entity/city.hbm.xml"/>
<mapping resource="com/cluster/entity/state.hbm.xml"/>
<mapping resource="com/cluster/entity/email.hbm.xml"/>
<mapping resource="com/cluster/entity/emailType.hbm.xml"/>
<mapping resource="com/cluster/entity/phone.hbm.xml"/>
<mapping resource="com/cluster/entity/phoneType.hbm.xml"/>
</session-factory>
</hibernate-configuration>
employee.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
'http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd'>
<hibernate-mapping package="com.cluster.entity" >
<class name="Employee" table="EMPLOYEE">
<id name="intEmployeeID" column="EMPLOYEE_ID">
<generator class="sequence">
<param name="sequence">EMPLOYEE_ID_SEQ</param>
</generator>
</id>
<property name="strFirstName" column = "FIRSTNAME"/>
<property name="strLastName" column="LASTNAME"/>
<property name="strDateOfBirth" column="DATE_OF_BIRTH"/>
<property name="strSalary" column="SALARY"/>
<many-to-one name="department" column="DEPARTMENT_ID" not-null = "true" class = "Department"/>
<set name="setAddressDetails" cascade="all" lazy="true">
<key column="EMPLOYEE_ID" not-null="true"></key>
<one-to-many class="AddressDetails"/>
</set>
<set name="setPhones" cascade="all" lazy="true">
<key column="EMPLOYEE_ID" not-null="true" cas></key>
<one-to-many class="Phone"/>
</set>
<set name="seEmails" cascade="all" lazy="true" >
<key column="EMPLOYEE_ID" not-null="true"></key>
<one-to-many class="Email"/>
</set>
</class>
</hibernate-mapping>
- Was ist "cas" ? aus den log-Attribut den Namen "cas" verbunden mit einem element-Typ "Schlüssel" werden muss, gefolgt von der ' = ' - Zeichen. Geschachtelte Ausnahme: Attribut name "cas" verbunden mit einem element-Typ "Schlüssel" werden muss, gefolgt von der ' = ' - Zeichen.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Check this out
Aus dem Protokoll angehängt " aus den log-Attribut den Namen "cas" verbunden mit einem element-Typ "Schlüssel" werden muss, gefolgt von der ' = ' - Zeichen. Geschachtelte Ausnahme: Attribut name "cas" verbunden mit einem element-Typ "Schlüssel" werden muss, gefolgt von der ' = ' - Zeichen."
ist die Ursache des Problems.
"es gibt kein Attribut mit dem Namen "cas".