-->
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.  [ 7 posts ] 
Author Message
 Post subject: Problem at mapping with foreign keys
PostPosted: Mon May 17, 2004 6:12 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey,

I got a problem with the mapping between 2 tables with foreign keys. The tables are:

CustomerOrder
-----------------
private Date createDate;
private Date deliveryDate;
private int price;
private int freightCost;
private int status;
private int paymentMode;
private int totalVolume;
private int totalWeight;
private int totalCost;
private int versionNo;
private CompositeCustOrdLinesID compOrderLineID;

CustomerOrderLine
----------------------
private String articleNo;
private String articleName;
private int quantity;
private int price;
private int volume;
private int weight;
private int deliveryDate;
private CompositeCustOrdLinesID compOrderLineID;

CompositeCustOrdLinesID (my key class holding the foreign keys)
------------------------------
private String countryCode; (CustomerOrder & CustomerOrderLine)
private String customerOrderNo; (CustomerOrder & CustomerOrderLine)
private String orderLineNo; (CustomerOrderLine)
private int mHashCode = -1;

The XML-file for the keys looks like this:

<hibernate-mapping>
<class name="net.sf.hibernate.CompositeCustOrdLinesID" table="COMPOSITECUSTORDLINES_T">
<composite-id>
<key-many-to-one name="countryCode" column="COUNTRYCODE" class="net.sf.hibernate.CustomerOrder"/>
<key-many-to-one name="customerOrderNo" column="CUSTOMERORDERNO" class="net.sf.hibernate.CustomerOrder"/>
< <key-property name="orderLineNo" column=ORDERLINENO type="string"/>
</composite-id>
</class>


Now, when I run my main it generate the following mapping fault.

12:01:17,788 ERROR XMLHelper:48 - Error parsing XML: XML InputStream(11) The content of elements must consist of well-formed character data or markup.
12:01:17,804 ERROR Configuration:292 - Could not configure datastore from input stream
org.dom4j.DocumentException: Error on line 11 of document : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup.
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:283)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:333)
at net.sf.hibernate.TestCustOrdOrderLines.configure(TestCustOrdOrderLines.java:24)
at net.sf.hibernate.TestCustOrdOrderLines.main(TestCustOrdOrderLines.java:130)
Nested exception:
org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:283)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:333)
at net.sf.hibernate.TestCustOrdOrderLines.configure(TestCustOrdOrderLines.java:24)
at net.sf.hibernate.TestCustOrdOrderLines.main(TestCustOrdOrderLines.java:130)
Funkar ej. ERROR = net.sf.hibernate.MappingException: Error reading resource: net/sf/hibernate/CompositeCustOrdLinesID.hbm.xml



Has anyone an idea how I'm gonna solve this? I don't get how to fix it.


Br. Johan


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 6:17 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Could this be your problem?

< <key-property name="orderLineNo" column=ORDERLINENO type="string"/>

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 6:20 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
No, but thanks for noticing it.

Got any other ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 6:27 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Nope, sorry the '<' was the only thing I noticed at first sight.

A closer look didn't reveal any problems I know, sorry again.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 7:42 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Is there any special "rule" how to manage foreign keys in both two tables with Many-to-one relation?

I got that so I'm wondering if that might be the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 8:00 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Think I'm goin' blind since I misspeld an attribute and that's why it didn't work.

Thx Peter for your help


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 8:29 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Got a new question for anyone. I got 3 foreign keys in CustomerOrderLines and 2 in CustomerOrder. Right now I'm getting this fault:

Foreign key (CUSTOMERORDERLINE_T [CUSTOMERORDERNO])) must have same number of columns as the referenced primary key (CUSTOMERORDER_T [CUSTOMERORDERNO,COUNTRYCODE])

Do I need any specific tags in the xml-files to manage this situation where different amout of keys are used?

CustomerORder
------------------

<class name="net.sf.hibernate.CustomerOrder" table="CUSTOMERORDER_T">
<composite-id name="compOrderLineID" class="net.sf.hibernate.CompositeCustOrdLinesID">
<key-property name="customerOrderNo" column="CUSTOMERORDERNO" type="string"/>
<key-property name="countryCode" column="COUNTRYCODE" type="string"/>
</composite-id>

<property name="deliveryDate" column="DELIVERYDATE"/>
<property name="price" column="PRICE"/>
<property name="freightCost" column="FREIGHTCOST"/>
<property name="status" column="STATUS"/>
<property name="paymentMode" column="PAYMENTMODE"/>
<property name="totalVolume" column="TOTALVOLUME"/>
<property name="totalWeight" column="TOTALWEIGHT"/>
<property name="totalCost" column="TOTALCOST"/>
<property name="versionNo" column="VERSIONNO"/>
</class>


CustomerOrderLines
------------------------
<class name="net.sf.hibernate.CustomerOrderLine" table="CUSTOMERORDERLINE_T">
<composite-id name="compOrderLineID" class="net.sf.hibernate.CompositeCustOrdLinesID">
<key-property name="orderLineNo" column="ORDERLINENO"/>
<key-many-to-one name="countryCode" column="COUNTRYCODE" class="net.sf.hibernate.CustomerOrder"/>
<key-many-to-one name="customerOrderNo" column="CUSTOMERORDERNO" class="net.sf.hibernate.CustomerOrder"/>
</composite-id>

<property name="articleNo" column="ARTICLENO"/>
<property name="articleName" column="ARTICLENAME"/>
<property name="quantity" column="QUANTITY"/>
<property name="price" column="PRICE"/>
<property name="volume" column="VOLUME"/>
<property name="weight" column="WEGHT"/>
<property name="deliveryDate" column="DELIVERYDATE"/>
</class>


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