Hi,
have a look at the classes generated, and you'll notice that for every
member Castor creates a second member with a has_ prefix. It's by using
the additional information available that Castor is able to marshal
'null' values.
I don't think there's a way to achieve the same by the means of using a
mapping file. I might be wrong, though.
Werner
Singh, Harjit wrote:
Here is the the class file, XML and mapping file
For the elements min-net-cap and xpns-shrng-id-nb I should see
null in the POJO but I don't see that. I see that when the POJOs are
created they have 0 assigned to them.
<net-cap>
<id>
<firm-crd-nb>145187</firm-crd-nb>
<flng-seq-nb>17</flng-seq-nb>
</id>
<min-net-cap></min-net-cap>
<alt-std-cmptn-fl>N</alt-std-cmptn-fl>
<xpns-shrng-id-nb></xpns-shrng-id-nb>
<xpns-shrng-argnt-fl>N</xpns-shrng-argnt-fl>
</net-cap>
<class cst:name="com.nasd.nma.pojo.NetCap">
<description>Default mapping for class
com.nasd.nma.pojo.NetCap</description>
<map-to cst:xml="net-cap"/>
<field cst:name="minNetCap" cst:type="java.lang.Long">
<bind-xml name="min-net-cap" node="element"/>
</field>
<field cst:name="xpnsShrngIdNb"
cst:type="java.lang.Long">
<bind-xml name="xpns-shrng-id-nb"
node="element"/>
</field>
<field cst:name="altStdCmptnFl"
cst:type="java.lang.String">
<bind-xml name="alt-std-cmptn-fl"
node="element"/>
</field>
<field cst:name="aplctFundgSrcs"
type="java.lang.Object" collection="set">
<bind-xml name="aplct-fundg-srcs"
node="element"/>
</field>
<field cst:name="aplctFirm"
cst:type="com.nasd.nma.pojo.AplctFirm">
<bind-xml name="aplct-firm" node="element"/>
</field>
<field cst:name="xpnsShrngArgntFl"
cst:type="java.lang.String">
<bind-xml name="xpns-shrng-argnt-fl"
node="element"/>
</field>
<field cst:name="id"
cst:type="com.nasd.nma.pojo.NetCapId">
<bind-xml name="id" node="element"/>
</field>
</class>
public class NetCap implements java.io.Serializable {
// Fields
private NetCapId id;
private AplctFirm aplctFirm;
private Long minNetCap;
private String altStdCmptnFl;
private String xpnsShrngArgntFl;
private Long xpnsShrngIdNb;
private Set aplctFundgSrcs = new HashSet(0);
// Constructors
/** default constructor */
public NetCap() {
}
/** minimal constructor */
public NetCap(NetCapId id, AplctFirm aplctFirm, String
altStdCmptnFl,
String xpnsShrngArgntFl, long xpnsShrngIdNb) {
this.id = id;
this.aplctFirm = aplctFirm;
this.altStdCmptnFl = altStdCmptnFl;
this.xpnsShrngArgntFl = xpnsShrngArgntFl;
this.xpnsShrngIdNb = xpnsShrngIdNb;
}
/** full constructor */
public NetCap(NetCapId id, AplctFirm aplctFirm, Long minNetCap,
String altStdCmptnFl, String xpnsShrngArgntFl, Long
xpnsShrngIdNb,
Set aplctFundgSrcs) {
this.id = id;
this.aplctFirm = aplctFirm;
this.minNetCap = minNetCap;
this.altStdCmptnFl = altStdCmptnFl;
this.xpnsShrngArgntFl = xpnsShrngArgntFl;
this.xpnsShrngIdNb = xpnsShrngIdNb;
this.aplctFundgSrcs = aplctFundgSrcs;
}
// Property accessors
public NetCapId getId() {
return this.id;
}
public void setId(NetCapId id) {
this.id = id;
}
public AplctFirm getAplctFirm() {
return this.aplctFirm;
}
public void setAplctFirm(AplctFirm aplctFirm) {
this.aplctFirm = aplctFirm;
}
public long getMinNetCap() {
return this.minNetCap;
}
public void setMinNetCap(Long minNetCap) {
this.minNetCap = minNetCap;
}
public String getAltStdCmptnFl() {
return this.altStdCmptnFl;
}
public void setAltStdCmptnFl(String altStdCmptnFl) {
this.altStdCmptnFl = altStdCmptnFl;
}
public String getXpnsShrngArgntFl() {
return this.xpnsShrngArgntFl;
}
public void setXpnsShrngArgntFl(String xpnsShrngArgntFl) {
this.xpnsShrngArgntFl = xpnsShrngArgntFl;
}
public long getXpnsShrngIdNb() {
return this.xpnsShrngIdNb;
}
public void setXpnsShrngIdNb(Long xpnsShrngIdNb) {
this.xpnsShrngIdNb = xpnsShrngIdNb;
}
public Set getAplctFundgSrcs() {
return this.aplctFundgSrcs;
}
public void setAplctFundgSrcs(Set aplctFundgSrcs) {
this.aplctFundgSrcs = aplctFundgSrcs;
}
-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 10, 2007 4:00 AM
To: [email protected]
Subject: Re: [castor-user] Default values
Hi,
can you supply us with a scenario of what you are trying to do. Iow,
show us example code, a mapping file fragment, etc. ?
Werner
Singh, Harjit wrote:
Hi there,
I have castor mapping for a pojo. I'm using Object types instead of
primitive type for Long and Ints. What I'm seeing is that where ever
myt XML doesn't have value for that element which corresponds to the
member by default it is setting it to 0. Is there any way I can
specify in the mapping file that use null as default when there is no
value ?
Thanks
- Harjit
This email, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this email is not the
intended recipient or his or her authorized agent, the reader is
hereby notified that any dissemination, distribution or copying of
this email is prohibited. If you have received this email in error,
please notify the sender by replying to this message and delete this
email immediately.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
This email, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this email is not the
intended recipient or his or her authorized agent, the reader is
hereby notified that any dissemination, distribution or copying of this
email is prohibited. If you have received this email in error,
please notify the sender by replying to this message and delete this
email immediately.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email