I've created two different types with ident="def" values that
represent candidate keys (not primary keys) to uniquely identify
instances of each type within that type (these are not globally unique
ids). Only one problem: the candidate keys deliberately overlap, so
the ident values for an instance of type B will often be the same as
an ident value of type A. This might have been an innocuous design
decision, except that jibx appears to be putting all id's for a
document into a single id->instance map, so that idents for type B
collide with type A during unmarshalling.
How do I tell jibx that the idents for type B should be stored in a
different id->instance map from the idents of type A?
Regards,
Ross
Here's a demo that successfully replicates the problem:
----- start jibx mapping file -----
<?xml version="1.0"?>
<binding>
<mapping name="demo" value-style="attribute" class="demo.Demo">
<collection name="items" field="items" item-type="demo.Item"
factory="demo.Demo.createList" />
<collection name="categories" field="categories"
item-type="demo.Category" factory="demo.Demo.createList" />
</mapping>
<mapping name="item" value-style="attribute" class="demo.Item">
<value name="id" field="id" ident="def" />
</mapping>
<mapping name="entry" value-style="attribute" class="demo.Entry">
<value name="item" field="item" ident="ref" type="demo.Item" />
</mapping>
<mapping name="category" value-style="attribute" class="demo.Category">
<value name="id" field="id" ident="def" />
<collection name="entries" field="entries" item-type="demo.Entry"
factory="demo.Category.createSet" />
</mapping>
</binding>
----- end jibx mapping file -----
----- start xml data file -----
<?xml version="1.0" encoding="UTF-8"?>
<demo>
<items>
<item id="book" />
</items>
<categories>
<category id="book">
<entries>
<entry item="book" />
</entries>
</category>
</categories>
</demo>
----- end xml data file -----
----- start exception message -----
Exception in thread "main" org.jibx.runtime.JiBXException: Duplicate
ID definition (line 7, col 25, in UTF-8)
at
org.jibx.runtime.impl.UnmarshallingContext.defineID(UnmarshallingContext.java:2287)
at
demo.Category.JiBX_demo_src_demo_demo_unmarshalAttr_1_0(Category.java)
at demo.JiBX_demo_src_demo_demoCategory_access.unmarshal()
at demo.JiBX_MungeAdapter.JiBX_demo_src_demo_demo_unmarshal_1_1()
at demo.Demo.JiBX_demo_src_demo_demo_unmarshal_1_0(Demo.java)
at demo.JiBX_demo_src_demo_demoDemo_access.unmarshal()
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537)
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2728)
at
net.bedrock.command.xml.AbstractLoadCommand.unmarshallDocument(AbstractLoadCommand.java:75)
at
net.bedrock.command.xml.AbstractLoadCommand.unmarshallDocument(AbstractLoadCommand.java:80)
at demo.LoadDemo.executeCommand(LoadDemo.java:31)
at net.bedrock.command.AbstractCommand.execute(AbstractCommand.java:170)
at
net.bedrock.command.CommandProxy.executeCommand(CommandProxy.java:131)
at net.bedrock.command.AbstractCommand.execute(AbstractCommand.java:170)
at net.bedrock.command.CommandList.executeCommand(CommandList.java:117)
at net.bedrock.command.AbstractCommand.execute(AbstractCommand.java:170)
at
net.bedrock.command.xml.LoadCommandList$1.doInTransactionWithoutResult(LoadCommandList.java:122)
at
org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
at
net.bedrock.orm.impl.AbstractEntity$AbstractDao.execute(AbstractEntity.java:597)
at
net.bedrock.orm.impl.AbstractEntity$AbstractDao.execute(AbstractEntity.java:589)
at
net.bedrock.command.xml.LoadCommandList.main(LoadCommandList.java:111)
----- end exception message -----
--
Ross Bagley
"Security is mostly a superstition. It does not exist in nature...
Life is either a daring adventure or nothing." -- Helen Keller
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users