Olá amigos.
Estou estudando o Hibernate para emprega-lo em uma aplicação que irei desenvolver. Porém, estou tendo problemas com o mapeamento. Já tentei um monte de coisas, no entanto, nada parece resolver.
Estou usando o PostgreSQL 8.1, no qual tenho a seguinte tabela:
id int4 NOT NULL DEFAULT nextval('contatos_seq'::regclass),
nome varchar(100),
endereco varchar(200),
bairro varchar(100),
cidade varchar(100),
estado varchar(2),
telefone varchar(20),
celular varchar(20),
email varchar(100),
CONSTRAINT contatos_pkey PRIMARY KEY (id)
Meu arquivo de mapeamento (Contatos.hbm.xml) está assim (considerando que o cabeçalho XML foi omitido):
<hibernate-mapping>
<class name="hibernateteste.Contato" table="contatos">
<id name="id" column="id" type="int">
<generator class="sequence">
<param name="sequence">contatos_seq</param>
</generator>
</id>
<property name="nome" type="string" column="nome"/>
<property name="endereco" type="string" column="endereco"/>
<property name="bairro" type="string" column="bairro"/>
<property name="cidade" type="string" column="cidade"/>
<property name="estado" type="string" column="estado"/>
<property name="telefone" type="string" column="telefone"/>
<property name="celular" type="string" column="celular"/>
<property name="email" type="string" column="email"/>
</class>
</hibernate-mapping>
Porém, quando tento conectar, tenho a seguinte exception:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource Contato.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at hibernateteste.Exemplo2.hibernateConnect(Exemplo2.java:34)
at hibernateteste.Exemplo2.<init>(Exemplo2.java:28)
at hibernateteste.Exemplo2$5.run(Exemplo2.java:348)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 16 more
Caused by: org.xml.sax.SAXParseException: Attribute "name" must be declared for element type "param".
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.startElement(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.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
... 17 more
Alguém sabe me dizer o que está havendo de errado?
Obrigado!