-->
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: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 4:50 am 
Newbie

Joined: Fri Jul 17, 2009 4:54 am
Posts: 17
Location: Near London
Somethins is either wrong with the java or the xml but i have no idea which it is. Just that it won't compile.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="EPOS.Database.Invoices" table="Invoices">
    <id column="ID" name="ID" type="long">
      <generator class="increment"/>
    </id>
    <property name="Date" column="InvDate"/>
    <property name="Ref"/>
    <property name="Supplier"/>
    <idbag name="Rows" table="Invoice_rows">
        <collection-id type="long" column="Invoice_row_ID's">
            <generator class="sequence"/>
        </collection-id>
        <key column="ID"/>
        <composite-element class="Row">
            <property name="ItemID" />
            <property name="Name" />
            <property name="Catergory" />
            <property name="BoxQuantity" />
            <property name="BoxNumber" />
            <property name="BoxPrice" />
        </composite-element>
    </idbag>

  </class>
</hibernate-mapping>


Code:
package EPOS.Database;

import EPOS.Amount;
import java.util.ArrayList;
import java.util.Collection;

public class Invoices {

    private long ID;
    private String Date = "";
    private String Ref = "";
    private String Supplier = "";

    private Collection Rows = new ArrayList();
   
    public Invoices() {}

    public void setID       (Long   ID)       {this.ID       = ID;}
    public void setDate     (String Date)     {this.Date     = Date;}
    public void setRef      (String Ref)      {this.Ref      = Ref;}
    public void setSupplier (String Supplier) {this.Supplier = Supplier;}
    public void setRows     (Collection Rows) {this.Rows     = Rows;}
   
    public long        getID       () {return ID;}
    public String      getDate     () {return Date;}
    public String      getRef      () {return Ref;}
    public String      getSupplier () {return Supplier;}
    public Collection  getRows     () {return Rows;}
}


Code:
Exception in thread "AWT-EventQueue-0" org.hibernate.MappingException: class Rows not found while looking for property: ItemID


Code virtual copied from Java Persistence with Hibernate. Obviously i misread something.


Last edited by etherkye on Tue Sep 08, 2009 6:39 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 5:58 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
you need to take a look at your java, i'm not going to point it out to you, but it is glaringly obvious.
think about Classes and Variable names.


Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 6:38 am 
Newbie

Joined: Fri Jul 17, 2009 4:54 am
Posts: 17
Location: Near London
Due to the fact my java is copied from the booked theres nothing i can personally see thats wrong. However as you seam to think the problem is in the classes i made the contents of the idbag into a sub class. Same error though so it's not done much good.

Code:
package EPOS.Database;

import EPOS.Amount;
import java.util.ArrayList;
import java.util.Collection;

public class Invoices {

    private long ID;
    private String Date = "";
    private String Ref = "";
    private String Supplier = "";

    private Collection Rows = new ArrayList();
   
    public Invoices() {}

    public void setID       (Long   ID)       {this.ID       = ID;}
    public void setDate     (String Date)     {this.Date     = Date;}
    public void setRef      (String Ref)      {this.Ref      = Ref;}
    public void setSupplier (String Supplier) {this.Supplier = Supplier;}
    public void setRows     (Collection Rows) {this.Rows     = Rows;}
   
    public long        getID       () {return ID;}
    public String      getDate     () {return Date;}
    public String      getRef      () {return Ref;}
    public String      getSupplier () {return Supplier;}
    public Collection  getRows     () {return Rows;}

    public class Row{
        private long ItemID;
        private String Name;
        private String Catergory;
        private String BoxQuantity;
        private String BoxNumber;
        private String BoxPrice;

        public Row() {}

        public void setItemID      (Long   ItemID)     {this.ItemID      = ItemID;}
        public void setName        (String Name)       {this.Name        = Name;}
        public void setCatergory   (String Catergory)  {this.Catergory   = Catergory;}
        public void setBoxQuantity (String BoxQuantity){this.BoxQuantity = BoxQuantity;}
        public void setBoxNumber   (String BoxNumber)  {this.BoxNumber   = BoxNumber;}
        public void setBoxPrice    (String BoxPrice)   {this.BoxPrice    = BoxPrice;}

        public long   getItemID      () {return ItemID;}
        public String getName        () {return Name;}
        public String getCatergory   () {return Catergory ;}
        public String getBoxQuantity () {return BoxQuantity;}
        public String getBoxNumber   () {return BoxNumber;}
        public String getBoxPrice    () {return BoxPrice;}
    }
}


Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 7:16 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
i've just been through the entire book and can't find your code example in there, i may have missed it, whereabouts are you looking?

the only section i see with idbags are pages 244 through 254, which deal with Image and Item classes.
the relationships between them is shown on page 251.

the Java is not shown in it's entireity, and yours contains no JPA annotations which are indicated in the book, so you may want to re-read the section.


Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 8:08 am 
Newbie

Joined: Fri Jul 17, 2009 4:54 am
Posts: 17
Location: Near London
Code on pg 254

using Rows instead of images.


Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Tue Sep 08, 2009 8:58 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
you need to have a thnk about how hibernate is meant to interpret what you tell it in your xml into your Java classes. you're missing an attribute on Row and another is mislabelled.

keep reading till the end of the chapter and see if that helps.


Top
 Profile  
 
 Post subject: Re: Compile error on idbag. Can't get the xml to work.
PostPosted: Wed Sep 09, 2009 5:08 am 
Newbie

Joined: Fri Jul 17, 2009 4:54 am
Posts: 17
Location: Near London
I honestly haven't got a clue whats missing. And reading further doesn't help because it starts to get into annotations which i am not currently using.

And also, my knowledge of what hibernate is trying to interpret is limited, as i really have no idea what it is and the main principles behind it still confuse me.

But i can't do any more work until this is fixed and it's causing me real problems.


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.