Here is my result map. I tried several variations, one using a
constructor within the association, and this one. Both of them
encounter the same problem:
<resultMap id="hubStatsMap"
type="com.masergy.lsp.db.bean.HubPairValue">
<result column="DATESTAMP" property="sampleDate" jdbcType="VARCHAR" />
<result column="COUNT" property="value" jdbcType="INTEGER" />
<association property="sourceHub" javaType="db.bean.Hub">
<result column="HUB" property="abbr" jdbcType="VARCHAR"
javaType="String"/>
<result column="HUB" property="label" jdbcType="VARCHAR"
javaType="String"/>
</association>
<association property="destinationHub" javaType="db.bean.Hub">
<result column="FAR_HUB" property="abbr" jdbcType="VARCHAR"
javaType="String"/>
<result column="FAR_HUB" property="label" jdbcType="VARCHAR"
javaType="String"/>
</association>
</resultMap>
Here is a sample of my retrieved data; no object was created for the row
SNGP, NWRK. I don't see anything unique about that data that would
cause a problem:
Row: SNGP, LONI, 2011-10-27 06:25:00, 13544
Row: SNGP, MIAS, 2011-10-27 06:25:00, 13095
Row: SNGP, NWRK, 2011-10-27 06:25:00, 208 <== no object created
Row: SNGP, NYCM, 2011-10-27 06:25:00, 30355
Row: SNGP, PARC, 2011-10-27 06:25:00, 1341
If I comment out the associations, all the objects get created. Any
idea what could be causing this problem?
Thanks.
--
Guy Rouillier
<settings>
<setting name="lazyLoadingEnabled" value="false"/>
<setting name="aggressiveLazyLoading" value="false"/>
</settings>
Unfortunately, I still have the same problem, with both or either one of
the above settings enabled. This is the first I'm aware that
associations have this problem. We use them widely; hopefully they are
not causing hidden problems elsewhere.
Appreciate any ideas on getting this to work. Thanks.
Maybe the problem is linked to issue 417.
Another possibility is that the Executor's connection is closed and the Executor is unable to get a new connection and fails silently.
But I think these cases would throw an exception instead of failing silently.
Christian
-----Message d'origine-----
De : mybati...@googlegroups.com [mailto:mybati...@googlegroups.com] De la part de Guy Rouillier
Envoyé : October-28-11 1:59 AM
À : mybati...@googlegroups.com
Objet : Re: Some objects with association not getting created
I don't want to get into the extreme details present in the sample
attached to the issue I opened, but the object type I'm trying to
instantiate looks like this:
public class PairValue {
private Date sampleDate = null;
private double value = 0;
}
public class HubPairValue extends PairValue {
private Hub sourceHub = null;
private Hub destinationHub = null;
}
What is happening is that when the association creates a HubPairValue
using a constructor, that in turn creates a PairValue. For the objects
that are not created, the sampleDate and value fields contain the same
values as a previous row, *even though* that row is for a different
combination of sourceHub and destinationHub. That is causing the
PairValue object to not be created; and since the PairValue object is
not created, neither is HubPairValue.
I notice that (some of the) Hub objects that have been previously
created are also not created the next time the same hub appears in a
different row. So apparently MyBatis is doing some kind of optimization
and not creating objects that it thinks already exist. I tried turning
off the global cache, and also on the select statement specifying
useCache="false", but the outcome did not change.
This is a pretty basic problem; I'm surprised it hasn't surfaced already.
--
Guy Rouillier
What is happening is that when the ResultMap creates a HubPairValue,
that in turn creates a PairValue. For the objects that are not created,
the sampleDate and value fields contain the same values as a previous
row, *even though* that row is for a different combination of sourceHub
and destinationHub. That is causing the PairValue object to not be
created; and since the PairValue object is not created, neither is
HubPairValue.
I don't know why commenting out the associations (which use constructors
to create sourceHub and destinationHub) results in all objects being
created.