I see. There's one simple change you can try for this, which is to add a <structure> element corresponding to the base class with no name and no property, and to use the type attribute on the access to the PK to again access the base class:

<structure name="hawb_status" type="TbScan">
  <value field="unique_id" name="unique_id"
    style="attribute" usage="optional"/>
  <structure type="BaseTbScan">
    <structure field="_comp_id" type="BaseTbScanPK">
      <value style="attribute" field="_dfPod" name="id"
        get-method="getDfPod"/>
      <value field="_dfPacknr" name="piece_no" usage="optional"/>
      <value field="_dfScandat" name="date" usage="optional"/>
      <value field="_dfScantime" name="time" usage="optional"/>
    </structure>
  </structure>
  ...

In theory, this should let you access the parent class information as part of the binding definition for the child class. I don't know that this has ever been tested, though, so no guarantees. If the current JiBX code doesn't let you do the <structure type="BaseTbScan">... you can enter it as a bug and I'll look into getting it fixed (probably for beta 4).

If this doesn't work, your other approach for now is to go back to using a <mapping> for TbScan that extends an abstract base <mapping> for BaseTbScan. You're going to have to make some change to the PK classes to get this to work, though, since you don't have a separate element for the PK and therefore can't define it using a <mapping>.

- Dennis

[EMAIL PROTECTED] wrote:

I got this exception when I tested your suggestion:

[bind] org.jibx.runtime.JiBXException: Field _comp_id not found in class TbScan at tag "structure"(line 9, col 44, in binding-hawb-status.xml)

It only works if the fields are defined in the TbScan and not in the base class.

Thanks

Anibal




Okay, I was confused on what you were trying to do in the original mapping. Abstract mappings are intended to be extended by other mappings and not used directly, and non-abstract mappings need to have an associated element name - you were trying to use abstract mappings as though they were regular mappings, just without an element name. I don't think you need to use mappings in your case, though - you can just put everything inline. Here's a cut-and-pasted version of your binding that should do what you want (untested, so there may be cut-and-paste errors, but it should at least show you the approach):

<mapping name="hawbs" class="States" ordered="false">
<value field="agent" name="agent" usage="optional"/>
<collection field="statusList" usage="optional">
<structure name="hawb_status" type="TbScan">
<value field="unique_id" name="unique_id" style="attribute"
usage="optional"/>
<structure field="_comp_id" type="TbScanPK" >
<value style="attribute" field="_dfPod" name="id" get-method="getDfPod"/>
<value field="_dfPacknr" name="piece_no" usage="optional"/>
<value field="_dfScandat" name="date" usage="optional"/>
<value field="_dfScantime" name="time" usage="optional"/>
</structure>
<structure name="status" usage="optional">
<value field="_dfScananlass" name="code" style="attribute"
usage="optional"/>
</structure>
</structure>
</collection>
</mapping>


I wouldn't think you actually want the <mapping> to be unordered, but left this in since you had it as part of the original version.

- Dennis





[EMAIL PROTECTED] wrote:



I do not want an abstract mapping to extend another abstract mapping.
There is a structure within the element with another mapping extending an abstract 
mapping.
These are my classes:

public class TbScan extends BaseTbScan {
        private String unique_id;
      ...
}

public abstract class BaseTbScan  implements Serializable {
        private TbScanPK _comp_id;
        // fields
        private java.lang.Integer _dfScananlass;
      ...
}


public class TbScanPK extends BaseTbScanPK { ... }

public class BaseTbScanPK implements Serializable {
        private java.lang.String _dfPod;
        private java.lang.Integer _dfPacknr;
        private java.sql.Date _dfScandat;
        private java.sql.Time _dfScantime;
      ...
}

How can I map this or is not possible?

Thanks

Anibal







-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users











-- Dennis M. Sosnoski Enterprise Java, XML, and Web Services Training and Consulting http://www.sosnoski.com Redmond, WA 425.885.7197




-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to