Hallo zusammen,
Ich hab da mal ein Problem mit dem Key-tag bei einer Map. Die Konfiguration ist OK, wenn ich die Map auskommentiere.
Wenn ich die wieder rein nehme bekomme ich fogende Exception
Full stack trace of any exception that occurs:
Code:
Caused by: org.hibernate.MappingException: Could not read mappings from resource: de/conpower/conweb/persistence/Function.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at de.conpower.conweb.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:50)
... 45 more
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 52 more
Caused by: org.xml.sax.SAXParseException: Attribute "name" must be declared for element type "key".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
Hibernate version: 3.1.3
Mapping documents:Code:
<hibernate-mapping>
<class name="de.conpower.conweb.persistence.Function" table="tbl_functions">
<id name="id" column="function_id">
<generator class="native">
<param name="sequence">tbl_functions_function_id_seq</param>
</generator>
</id>
<property name="name" column="function_name" not-null="true" />
<map name="userRights" table="tbl_map_userrights" >
<key name="function_id" />
<map-key type="long" column="usr_id" />
<element type="int" column="rights" />
</map>
</class>
</hibernate-mapping>
Java-Source:Code:
public class Function extends DataObject {
private Long id;
private String name;
/**
* Map<usr_id, rights>
*/
private Map<Long, Integer> userRights = new TreeMap<Long, Integer> ();
public Function () {
}
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public Map<Long, Integer> getUserRights () {
return userRights;
}
public void setUserRights (Map<Long, Integer> newMap) {
userRights = newMap;
}
... weitere implementierung
}
Name and version of the database you are using: Postgres 8.1.3
Datenbankstruktur:Code:
+-----------------+
|tbl_functions: |
+-----------------+
|function_id (PK) |
|function_name | (bezeichnung der Funktion)
+-----------------+
+-------------------+
|tbl_map_userrights |
+-------------------+
|ur_id (PK) |
|function_id (FK) | (Fremdschlüssel zum PK der Tabelle tbl_functions)
|rights | (Berechtigungsschlüssel)
+-------------------+
Danke
weisnix