-->
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.  [ 4 posts ] 
Author Message
 Post subject: primary error
PostPosted: Thu Aug 11, 2005 9:29 am 
Newbie

Joined: Wed Jul 13, 2005 10:10 am
Posts: 8
Location: Brasil
hi
i'm beginning in hibernate

I made my first one mapping, but it gave an error

it's error
Code:
Exception in thread "main" org.hibernate.MappingException: Error reading resource: uti/Paciente.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
        at Prontuario.<init>(Prontuario.java:33)
        at Prontuario.main(Prontuario.java:82)
Caused by: org.hibernate.MappingException: invalid mapping
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
        ... 8 more


mapping:
Code:
<?xml version='1.0' encoding='utf-8'?>

<!--
    Document   : Hibernate.cfg.xml
    Created on : 9 de Agosto de 2005, 10:58
    Author     : gian
    Description:
        Purpose of the document follows.
-->

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="connection.url">jdbc:postgresql://localhost:5432/UTI</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password">telmed</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>

        <mapping resource="uti/Paciente.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


and

Code:

<?xml version='1.0' encoding='utf-8'?>

<!--
    Document   : Paciente.hbm.xml
    Created on : 8 de Agosto de 2005, 10:48
    Author     : gian
    Description:
        Purpose of the document follows.
-->

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-mapping>
    <class name="Paciente"
           table="PACIENTE">
        <id
            name = "codPac"
            column = "CODPAC">
            <generactor class = "native"/>
         </id>
         
         <property
            name = "numeroRegistro"
            column = "NUM_REGISTRO"
            type = "int"/>
       
         <property
            name = "nome"
            column = "NOME"
            type = "string"/>
           
         <property
            name = "dataNasc"
            column = "DATA_NASC"
            type = "date"/>
           
         <property
            name = "sexo"
            column = "SEXO"
            type = "string"/>

         <property
            name = "fone01"
            column = "FONE01"
            type = "string"/>
           
         <property
            name = "fone02"
            column = "FONE02"
            type = "string"/>
           
         <property
            name = "complemento"
            column = "COMPLEMENTO"
            type = "string"/>
           
         <property
            name = "peso"
            column = "PESO"
            type = "float"/>
           
         <property
            name = "altura"
            column = "ALTURA"
            type = "float"/>
           
         <property
            name = "nomeMae"
            column = "NOME_MAE"
            type = "string"/>
           
         <property
            name = "naturalMunicipio"
            column = "NATURAL_MUNICIPIO"
            type = "string"/>
           
         <property
            name = "naturalUF"
            column = "NATURAL_UF"
            type = "string"/>
           
         <property
            name = "tipoSang"
            column = "TIPO_SANG"
            type = "string"/>
           
         <property
            name = "rhSang"
            column = "RG_SANG"
            type = "string"/>
           
         <property
            name = "uid"
            column = "UID"
            type = "string"/>
         
           
     </class>
</hibernate-mapping>



somebody can help me?

tanks :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 9:58 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
The doctype for you mapping must be hibernate-mapping not hibernate-configuration

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 10:16 am 
Newbie

Joined: Wed Jul 13, 2005 10:10 am
Posts: 8
Location: Brasil
scesbron wrote:
The doctype for you mapping must be hibernate-mapping not hibernate-configuration


tanks, I modified but it the same continues giving error

error:
Code:
Exception in thread "main" org.hibernate.MappingException: Error reading resource: uti/Paciente.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
        at Prontuario.<init>(Prontuario.java:33)
        at Prontuario.main(Prontuario.java:82)
Caused by: org.hibernate.MappingException: invalid mapping
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
        ... 8 more
Caused by: org.xml.sax.SAXParseException: Element type "generactor" must be declared.
        at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
        at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1807)
        at org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:3633)
        at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1229)
        at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
        ... 9 more


changed mapping
Code:
<?xml version='1.0' encoding='utf-8'?>

<!--
    Document   : Paciente.hbm.xml
    Created on : 8 de Agosto de 2005, 10:48
    Author     : gian
    Description:
        Purpose of the document follows.
-->

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="uti.Paciente"
           table="PACIENTE">
        <id
            name = "codPac"
            column = "CODPAC">
            <generactor class = "native"/>
         </id>
         
         <property
            name = "numeroRegistro"
            column = "NUM_REGISTRO"
            type = "int"/>
       
         <property
            name = "nome"
            column = "NOME"
            type = "string"/>
           
         <property
            name = "dataNasc"
            column = "DATA_NASC"
            type = "date"/>
           
         <property
            name = "sexo"
            column = "SEXO"
            type = "string"/>

         <property
            name = "fone01"
            column = "FONE01"
            type = "string"/>
           
         <property
            name = "fone02"
            column = "FONE02"
            type = "string"/>
           
         <property
            name = "complemento"
            column = "COMPLEMENTO"
            type = "string"/>
           
         <property
            name = "peso"
            column = "PESO"
            type = "float"/>
           
         <property
            name = "altura"
            column = "ALTURA"
            type = "float"/>
           
         <property
            name = "nomeMae"
            column = "NOME_MAE"
            type = "string"/>
           
         <property
            name = "naturalMunicipio"
            column = "NATURAL_MUNICIPIO"
            type = "string"/>
           
         <property
            name = "naturalUf"
            column = "NATURAL_UF"
            type = "string"/>
           
         <property
            name = "tipoSang"
            column = "TIPO_SANG"
            type = "string"/>
           
         <property
            name = "rhSang"
            column = "RG_SANG"
            type = "string"/>
           
         <property
            name = "uid"
            column = "UID"
            type = "string"/>
         
     </class>
</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 10:25 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Quote:
type "generactor" must be declared.


You've misspelled generator

Quote:
<id
name = "codPac"
column = "CODPAC">
<generactor class = "native"/>
</id>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.