Bonjour,
Je suis débutant avec Hibernate et je suis entrain d'essayer de créer une couche d'accès aux données avec ce dernier, cependant je rencontre de nombreuses difficultés,...
Pour faire vite, le contenu de mon fichier cfg est comme tel:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory >
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@egp-sdlainpa1:1521:XE</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">dih</property>
<property name="hibernate.connection.password">i2b2-2402</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for Oracle (any version) -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<mapping resource="ObservationFact.hbm.xml"/>
<mapping resource="VisitDimension.hbm.xml"/>
<mapping resource="ProviderDimension.hbm.xml"/>
<mapping resource="PatientDimension.hbm.xml"/>
<mapping resource="ConceptDimension.hbm.xml"/>
</session-factory>
</hibernate-configuration>
et voici le contenu de l'un de mes fichiers de mapping
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="hibernate.i2b2">
<class name="ObservationFact" table="OBSERVATION_FACT">
<composite-id>
<key-many-to-one name="ENCOUNTER_NUM" column="ENCOUNTER_NUM" class="ObservationFact" />
<key-many-to-one name="CONCEPT_CD" column="CONCEPT_CD" class="ObservationFact" />
<key-many-to-one name="PROVIDER_ID" column="PROVIDER_ID" class="ObservationFact"/>
<key-property name="START_DATE" column="START_DATE" type="date" />
<key-property name="MODIFIER_CD" column="MODIFIER_CD" type="string" />
</composite-id>
<many-to-one name="PATIENT_NUM" column="PATIENT_NUM" class="ObservationFact"
not-null="true"/>
<property name="VALTYPE_CD" type="string"/>
<property name="TVAL_CHAR" type="string"/>
<property name="NVAL_NUM" type="big_decimal"/>
<property name="VALUEFLAG_CD" type="char"/>
<property name="QUANTITY_NUM" type="big_decimal"/>
<property name="UNITS_CD" type="string"/>
<property name="END_DATE" type="date"/>
<property name="LOCATION_CD" type="string"/>
<property name="CONFIDENCE_NUM" type="big_decimal"/>
<property name="OBSERVATION_BLOB" type="big_decimal"/>
<property name="UPDATE_DATE" type="date"/>
<property name="DOWNLOAD_DATE" type="date"/>
<property name="IMPORT_DATE" type="date"/>
<property name="SOURCESYSTEM_CD" type="string"/>
<property name="UPLOAD_ID" type="big_decimal"/>
<property name="OBSERVATION_BLOB2" type="clob"/>
<meta attribute="sync-DAO">true</meta>
</class>
</hibernate-mapping>
j'ai une clé primaire composée et qui comporte des clés étrangères !!!
le message d'erreur est comme tel:
Code:
INFO: hibernate.properties not found
15 mai 2009 11:47:25 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
15 mai 2009 11:47:25 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
15 mai 2009 11:47:25 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
15 mai 2009 11:47:25 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
15 mai 2009 11:47:25 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : ObservationFact.hbm.xml
15 mai 2009 11:47:25 org.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(47) 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)*)".
Exception in thread "main" java.lang.ExceptionInInitializerError
at hibernateI2b2.Test.main(Test.java:32)
Caused by: java.lang.RuntimeException: Problème de configuration : Could not parse mapping document from resource ObservationFact.hbm.xml
at hibernateI2b2.HibernateUtil.<clinit>(HibernateUtil.java:38)
... 1 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource ObservationFact.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:602)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1621)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at hibernateI2b2.HibernateUtil.<clinit>(HibernateUtil.java:36)
... 1 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:535)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:599)
... 8 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.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:532)
... 9 more
cela fait presque une semaine que je bute sur ce problème !!! j'espère que vous pourriez m'aider et je vous en remercie d'avance...