Here is how the problem occurs:
let's say I have an object A that contains a list of objects B. I first persist an A containing 1 B. Then I retrieve this object A (using find), I add a new object B to its list and I do a merge on A. When I do a find on my object A, I get my first object B well persisted, but the second one has only null fields.
Note that these B objects are instances of an FPML class, generated from the XML description of the library.
Please let me know if something is missing in my explanation.
Update:
The problem occurs with InstrumentId objects.
@Test
public void testInstrumentIdPersistenceAndUpdate () throws Exception {
InstrumentId instrumentId = InstrumentIdUtils.produceInstrument("SX5E:IND", InstrumentIdScheme.BLOOMBERG);
UnderlyingDefinition underlyingDefinition1 = new UnderlyingDefinition();
underlyingDefinition1.setSymbol("SX5E:IND");
underlyingDefinition1.setCurrency(CurrencyUtils.EUR);
underlyingDefinition1.addInstrumentId(instrumentId);
ProductDefinition productDefinition1 = new ProductDefinition("PUT");
productDefinition1.addInstrumentDefinition(underlyingDefinition1);
Universe universe = new Universe();
universe.addProductDefinition(productDefinition1);
universe.setName("channel.test-3");
universe.setUri(new URI("urn:mapp3.channel.test-3"));
entityManager.persist(universe);
InstrumentId instrumentId1 = InstrumentIdUtils.produceInstrument("NES:IND", InstrumentIdScheme.BLOOMBERG);
underlyingDefinition1.addInstrumentId(instrumentId1);
entityManager.merge(universe);
InstrumentId instrumentId2 = InstrumentIdUtils.produceInstrument("TOCH:IND", InstrumentIdScheme.BLOOMBERG);
underlyingDefinition1.addInstrumentId(instrumentId2);
// entityManager.merge(universe);
Universe u = entityManager.find(Universe.class, "urn:mapp3.channel.test-3");
}
mapping file
<entity name="InstrumentId" class="org.fpml.v57.InstrumentId">
<table name="T_INSTRUMENT_ID"/>
<attributes>
<id name="value" access="PROPERTY">
<column name="VALUE" length="100"/>
</id>
<id name="instrumentIdScheme" access="FIELD">
<column name="INSTRUMENT_ID_SCHEME" length="100"/>
</id>
</attributes>
</entity>
here is the generated pojo
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InstrumentId", propOrder = {
"value"
})
public class InstrumentId
extends ModelObject
implements Serializable
{
@XmlValue
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String value;
@XmlAttribute(name = "instrumentIdScheme", required = true)
@XmlSchemaType(name = "anyURI")
protected String instrumentIdScheme;