-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem mit einer Wertklasse (component)
PostPosted: Mon Aug 07, 2006 5:57 pm 
Regular
Regular

Joined: Mon Jul 31, 2006 4:59 pm
Posts: 53
Benutze Hibernate 3.2 und ich versuche meine Klasse "Termin" zusammen mit meiner Klasse "Zeitpunkt" zu speichern. "Zeitpunkt" soll eine Wertklasse sein. Ein Zeitpunkt wird nur als Teil des Geschäftsobjekts "Termin" gespeichert. Leider funktioniert das noch nicht so wie ich will... :(


Habe folgende Tabelle in der MySql5-Datenbank:

Code:
CREATE TABLE `termin` (
`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`titel` VARCHAR( 200 ) NOT NULL ,
`beschreibung` VARCHAR( 200 ) NOT NULL ,
`zeit` TIMESTAMP NOT NULL ,
`ort` VARCHAR( 200 ) NOT NULL
) TYPE = innodb;




Die Klasse "Zeitpunkt"
Code:
package uebung1Package;

public class Zeitpunkt {
   private int _minute;
   private int _stunde;
   private int _tag;
   private int _monat;
   private int _jahr;
   
   public int get_jahr() {
      return _jahr;
   }
   public void set_jahr(int _jahr) {
      this._jahr = _jahr;
   }
   public int get_minute() {
      return _minute;
   }
   public void set_minute(int _minute) {
      this._minute = _minute;
   }
   public int get_monat() {
      return _monat;
   }
   public void set_monat(int _monat) {
      this._monat = _monat;
   }
   public int get_stunde() {
      return _stunde;
   }
   public void set_stunde(int _stunde) {
      this._stunde = _stunde;
   }
   public int get_tag() {
      return _tag;
   }
   public void set_tag(int _tag) {
      this._tag = _tag;
   }
   

}



Die Klasse "Termin"
Code:
package uebung1Package;


public class Termin
{
  private long _id;
  private String _titel;
  private String _beschreibung;
  private String _ort;
  private Zeitpunkt _zeit;
 
 
  public void setZeit (Zeitpunkt z)
  {
     _zeit = z;
  }
 
  public Zeitpunkt getZeit()
  {
     return _zeit;
  }
 
  public String getTitel ()
  {
    return _titel;
  }

  public void setTitel (String titel)
  {
    _titel = titel;
  }

 
  public String getBeschreibung ()
  {
    return _beschreibung;
  }

  public void setBeschreibung (String beschreibung)
  {
    _beschreibung = beschreibung;
  }

  public String getOrt ()
  {
    return _ort;
  }

  public void setOrt (String ort)
  {
    _ort = ort;
  }

  public long getId ()
  {
    return _id;
  }

  public void setId (long id)
  {
    _id = id;
  }
}



Mapping "Termin.hbm.xml"
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

   <class name="uebung1Package.Termin">
      <component name="zeit">
         <property name="minute"/>
         <property name="stunde"/>
         <property name="tag"/>
         <property name="monat"/>
         <property name="jahr"/>
      </component>
      
   
   
      <id name="id" type="long">
         <generator class="assigned">
         </generator>
      </id>
      
      <property name="titel" />
      <property name="beschreibung" />
      <property name="zeitpunkt" column="zeit" type="timestamp"/>
      <property name="ort" type="string"/>
      
      
      
   </class>
   </hibernate-mapping>



Die "Hibernate.cfg.xml" (müsste eigentlich stimmen)
Code:
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <mapping resource="uebung1Package/Termin.hbm.xml"/>
   </session-factory>
</hibernate-configuration>



So das waren nun die wichtigsten Dateien. Die Fehlermeldung lautet:
Code:
07.08.2006 23:50:02 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2 cr2
07.08.2006 23:50:02 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
07.08.2006 23:50:02 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
07.08.2006 23:50:02 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
07.08.2006 23:50:02 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
07.08.2006 23:50:02 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
07.08.2006 23:50:03 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: uebung1Package/Termin.hbm.xml
07.08.2006 23:50:03 org.hibernate.util.XMLHelper$ErrorLogger error
SCHWERWIEGEND: Error parsing XML: XML InputStream(31) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
07.08.2006 23:50:03 uebung1Package.HibernateUtil <clinit>
SCHWERWIEGEND: Building SessionFactory failed.
org.hibernate.MappingException: Could not read mappings from resource: uebung1Package/Termin.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:518)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1506)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1474)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1453)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1427)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1347)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1333)
   at uebung1Package.HibernateUtil.<clinit>(HibernateUtil.java:34)
   at uebung1Package.TerminDAO.<init>(TerminDAO.java:10)
   at uebung1Package.TerminServlet.doGet(TerminServlet.java:27)
   at uebung1Package.TerminServlet.doPost(TerminServlet.java:72)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:458)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:515)
   ... 26 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:455)
   ... 27 more
07.08.2006 23:50:03 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet TerminServlet threw exception
java.lang.ExceptionInInitializerError
   at uebung1Package.HibernateUtil.<clinit>(HibernateUtil.java:43)
   at uebung1Package.TerminDAO.<init>(TerminDAO.java:10)
   at uebung1Package.TerminServlet.doGet(TerminServlet.java:27)
   at uebung1Package.TerminServlet.doPost(TerminServlet.java:72)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: uebung1Package/Termin.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:518)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1506)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1474)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1453)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1427)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1347)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1333)
   at uebung1Package.HibernateUtil.<clinit>(HibernateUtil.java:34)
   ... 19 more
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:458)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:515)
   ... 26 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:455)
   ... 27 more



Kann mir jemand helfen dieses Problem zu lösen? Vielen dank im voraus!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 4:59 am 
Beginner
Beginner

Joined: Thu Jul 20, 2006 12:08 pm
Posts: 21
Location: Germany
hallo hiperman,

auch hier wie bei deinem anderen posting auch : erst "id" und dann "component". Hibernate ist was die Reihenfolge der Elemente in den XML-files betrifft sehr pingelich.

grüße

marlon

_________________
marlon
---
don't hesitate to rate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.