-->
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.  [ 3 posts ] 
Author Message
 Post subject: java.lang.RuntimeException: net.sf.hibernate.MappingExceptio
PostPosted: Mon Mar 28, 2005 5:18 am 
Newbie

Joined: Sat Mar 26, 2005 6:31 am
Posts: 14
Hello,

I am trying to a many-to-many list inside as joind-subclass.
If I remove the List from the mapping file. I do not get any errors.
I am already trying for day's so please HELP ME!

I use HBN2.1.8

This is the mapping file and the failure trace:

<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="eindwerk.stockbeheer.Artikel"
table="Artikel"
>

<id
name="artikelId"
column="artikelId"
type="java.lang.Integer"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Artikel.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="minimumStock"
type="java.lang.Float"
column="minimumStock"
/>

<property
name="omschrijving"
type="java.lang.String"
column="omschrijving"
/>

<property
name="stockageEenheid"
type="java.lang.String"
column="stockageEenheid"
/>

<property
name="transportKosten"
type="java.lang.Float"
column="transportKosten"
/>

<property
name="verpakking"
type="java.lang.String"
column="verpakking"
/>

<property
name="artikelNr"
type="java.lang.Integer"
column="artikelNr"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Artikel.xml
containing the additional properties and place it in your merge dir.
-->

<joined-subclass
name="eindwerk.stockbeheer.StockArtikel"
table="stockArtikel"
>
<key
column="artikelId"
/>
<property
name="geleverd"
type="boolean"
column="geleverd"
/>

<property
name="prijs"
type="java.lang.Float"
column="prijs"
/>

</joined-subclass>
<joined-subclass
name="eindwerk.stockbeheer.StandaardArtikel"
table="standaardArtikel"
>
<key
column="artikelId"
/>

<list
role="leveranciers"
table="standaardArtikelLeverancier"
lazy="false"
cascade="none"
>

<key
column="artikelId"
>
</key>

<index
column="leveranciersIndex"
/>

<many-to-many
class="eindwerk.stockbeheer.Leverancier"
column="leveranciersId"
outer-join="auto"
/>

</list>

</joined-subclass>

</class>

</hibernate-mapping>

java.lang.RuntimeException: net.sf.hibernate.MappingException: Error reading resource: eindwerk/stockbeheer/Artikel.hbm.xml
at eindwerk.hibernate.HibernatePersistence.<init>(HibernatePersistence.java:35)
at eindwerk.hibernate.HibernatePersistence.getInstance(HibernatePersistence.java:41)
at eindwerk.hibernate.HibernateSession.currentSession(HibernateSession.java:39)
at eindwerk.stockbeheer.test.TestArtikel.testNieuwStockArtikelInDB(TestArtikel.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: Error reading resource: eindwerk/stockbeheer/Artikel.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:358)
at eindwerk.hibernate.HibernatePersistence.<init>(HibernatePersistence.java:28)
... 18 more
Caused by: net.sf.hibernate.MappingException: java.lang.NullPointerException
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:297)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:355)
... 19 more
Caused by: java.lang.NullPointerException
at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:509)
at net.sf.hibernate.cfg.Binder$3.create(Binder.java:1441)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1028)
at net.sf.hibernate.cfg.Binder.bindJoinedSubclass(Binder.java:216)
at net.sf.hibernate.cfg.Binder.handleJoinedSubclass(Binder.java:1087)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1058)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:362)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:289)
... 20 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 5:20 am 
Newbie

Joined: Sat Mar 26, 2005 6:31 am
Posts: 14
This is the code:

/*
* Created on 12-mrt-2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package eindwerk.stockbeheer;

import java.util.Set;

/**
* @hibernate.class table="Artikel"
*
*/
public class Artikel {

protected Integer artikelId;
protected Integer artikelNr;
protected String omschrijving;
protected String stockageEenheid;
protected Float transportKosten;
protected String verpakking;
protected Float minimumStock;
//protected Munt prijseenheid;

/**
* @hibernate.property
* column="minimumStock"
*/
public Float getMinimumStock() {
return minimumStock;
}
/**
* @param minimumStock The minimumStock to set.
*/
public void setMinimumStock(Float minimumStock) {
this.minimumStock = minimumStock;
}
/**
* @hibernate.property
* column="omschrijving"
*/
public String getOmschrijving() {
return omschrijving;
}
/**
* @param omschrijving The omschrijving to set.
*/
public void setOmschrijving(String omschrijving) {
this.omschrijving = omschrijving;
}
/**
* @hibernate.property
* column="stockageEenheid"
*/
public String getStockageEenheid() {
return stockageEenheid;
}
/**
* @param stockageEenheid The stockageEenheid to set.
*/
public void setStockageEenheid(String stockageEenheid) {
this.stockageEenheid = stockageEenheid;
}
/**
* @hibernate.property
* column="transportKosten"
*/
public Float getTransportKosten() {
return transportKosten;
}
/**
* @param transportKosten The transportKosten to set.
*/
public void setTransportKosten(Float transportKosten) {
this.transportKosten = transportKosten;
}
/**
* @hibernate.property
* column="verpakking"
*/
public String getVerpakking() {
return verpakking;
}
/**
* @param verpakking The verpakking to set.
*/
public void setVerpakking(String verpakking) {
this.verpakking = verpakking;
}
/**
* @hibernate.property
* column="artikelNr"
*/
public Integer getArtikelNr() {
return artikelNr;
}
/**
* @param artikelNr The artikelNr to set.
*/
public void setArtikelNr(Integer artikelNr) {
this.artikelNr = artikelNr;
}
/**
* @hibernate.id
* generator-class="native"
* column="artikelId"
* unsaved-value="null"
*/
public Integer getArtikelId() {
return artikelId;
}
/**
* @param id The id to set.
*/
public void setArtikelId(Integer artikelId) {
this.artikelId = artikelId;
}
public boolean equals(Object other) {
if (this == other) return true;
//werkt instanceof ook met subKlassen?
if (!(other instanceof Artikel)) return false;

final Artikel art = (Artikel) other;

if (!getArtikelId().equals(art.getArtikelId())) return false;
return true;
}
public int hashCode() {
int result;
result = getArtikelId().hashCode();
return result;
}
}
-------------------------------------------------------

/*
* Created on 14-mrt-2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package eindwerk.stockbeheer;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
* @author Steven
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/


/**
* @hibernate.joined-subclass table="standaardArtikel"
* @hibernate.joined-subclass-key column="artikelId"
*/
public class StandaardArtikel extends Artikel{
protected List leveranciers = new ArrayList();

/**
* @hibernate.list table="standaardArtikelLeverancier"
* @hibernate.collection-many-to-many class="eindwerk.stockbeheer.Leverancier" column="leveranciersId"
* @hibernate.collection-key column="artikelId"
* @hibernate.collection-index column="leveranciersIndex"
*/
public List getLeveranciers() {
return leveranciers;
}
/**
* @param leveranciers The leveranciers to set.
*/
public void setLeveranciers(List leveranciers) {
this.leveranciers = leveranciers;
}
}
--------------------------------------------------------------

/*
* Created on 14-mrt-2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package eindwerk.stockbeheer;

import java.io.Serializable;

/**
* @author Steven
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @hibernate.joined-subclass table="stockArtikel"
* @hibernate.joined-subclass-key column="artikelId"
*/
public class StockArtikel extends Artikel implements Serializable{
//protected Leveranier leverancier;
protected Float prijs;
protected boolean geleverd;


/**
* @return Returns the geleverd.
*/
/**
* @hibernate.property
* column="geleverd"
*/
public boolean isGeleverd() {
return geleverd;
}
/**
* @param geleverd The geleverd to set.
*/
public void setGeleverd(boolean geleverd) {
this.geleverd = geleverd;
}
/**
* @return Returns the prijs.
* @hibernate.property
* column="prijs"
*/
public Float getPrijs() {
return prijs;
}
/**
* @param prijs The prijs to set.
*/
public void setPrijs(Float prijs) {
this.prijs = prijs;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 8:18 am 
Newbie

Joined: Sat Mar 26, 2005 6:31 am
Posts: 14
I have found the fault.

I should use 2.0 instead of 1.1 in the mapping-file DOCTYPE settings


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