Hibernate version:
3.1 on MySQL 4.1 & JDK 5.0
Bonjour,
j'utilise une gestion externe pour mes clé composées.
j'ai donc un objet "TariffId" pour clé de mon objet mappé "Tariff".
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="Tariff" table="TARIFF" catalog="maBDD">
<composite-id name="id" class="TariffId">
<key-property name="idtariff" type="short" column="idtariff" />
<key-property name="identerprise" type="integer" column="identerprise"/>
</composite-id>
<property name="libtariff" type="string">
<column name="libtariff" length="25" />
</property>
<property name="typtariff" type="short">
<column name="typtariff" />
</property>
</class>
</hibernate-mapping>
Tous les objets sont dans le même package.
Les fichiers de mapping sont dans un dossier à part
or a la création de ma sessionfactory il charge bien tous les objet mappé et me sort cette exception sur mon "ID"
Code:
DEBUG [Configuration] sessionA_M<-org.dom4j.tree.DefaultAttribute@1bfc93a [Attribute: name resource value "hibernateMapping/Tariff.hbm.xml"]
INFO [Configuration] Reading mappings from resource: hibernateMapping/Tariff.hbm.xml
DEBUG [DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/
DEBUG [DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath
INFO [HbmBinder] Mapping class: Tariff -> TARIFF
DEBUG [HbmBinder] Mapped property: idtariff -> idtariff
DEBUG [HbmBinder] Mapped property: identerprise -> identerprise
DEBUG [HbmBinder] Mapped property: id -> idtariff, identerprise
DEBUG [HbmBinder] Mapped property: libtariff -> libtariff
DEBUG [HbmBinder] Mapped property: typtariff -> typtariff
....
DEBUG [Configuration] resolving reference to class: Tariff
....
Exception in thread "Thread-0" java.lang.ExceptionInInitializerError
at clientserver.ServerRMI.run(ServerRMI.java:54)
Caused by: java.lang.RuntimeException: Problème de configuration : component class not found: TariffId
at datacontrol.HibernateUtil.<clinit>(HibernateUtil.java:26)
... 1 more
Caused by: org.hibernate.MappingException: component class not found: TariffId
at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:140)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:79)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:33)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:126)
at org.hibernate.mapping.Component.getType(Component.java:160)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.RootClass.validate(RootClass.java:193)
at org.hibernate.cfg.Configuration.validate(Configuration.java:983)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1147)
at datacontrol.HibernateUtil.<clinit>(HibernateUtil.java:24)
... 1 more
Caused by: java.lang.ClassNotFoundException: TariffId
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
... 11 more
j'ai un peu épuré le log pour gardé l'essentiel.
Mon HibernateUtil.java est l'original donné par cette excellente Doc Hibernate.
Merci.