Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Example using EclipseLink+MongoDB+XML Mappings

I have done enough sleuthing on this problem to suspect a bug in EclipseLink. To test, I made a mock class and persisted it using annotations instead of XML mappings.

If I annotate the mock class with @NoSQL(dataFormat-DataFormatType.MAPPED) -- WORKS CORRECTLY
If I annotate the mock class with @NoSQL or @NoSQL(dataFormat-DataFormatType.XML) -- ALL VALUES ARE {"#text": null}

Thus the #text-null problem does in fact arise from the DataFormatType, and I verified that the dataFormat can be set using annotations.

That leaves two possibilities: either I am not correctly making my <no-sql /> tag, or the <no-sql /> tag processor doesn't support dataFormat.

To test the first possibility I tried every conceivable variation of that tag:

<no-sql dataFormat="DataFormatType.MAPPED" />

<no-sql dataFormat="org.eclipse.persistence.nosql.annotations.DataFormatType.MAPPED" />

<no-sql dataFormat="MAPPED" />

<no-sql>

    <dataFormat>DataFormatType.MAPPED</dataFormat>

</no-sql>

<no-sql>

    <dataFormat>MAPPED</dataFormat>

</no-sql>

<no-sql>

    <dataFormat>org.eclipse.persistence.nosql.annotations.DataFormatType.MAPPED</dataFormat>

</no-sql>


None of those worked, and the first one is right, I'm pretty sure. Furthermore, the EclipseLink spec says to use <no-sql dataType="mongo_collection_name" /> to define the collection name in the database, but I can't get dataType to work either. (http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/NoSQL/Configuring)

I can't be sure until I go grok the EclipseLink code but to me this smells like an incomplete implementation of XML mapping support. I would be grateful for any advice or comments.

Nicholas



On Wed, May 29, 2013 at 8:00 PM, Nicholas Keene <nicholas@xxxxxxxxx> wrote:
Hello again, ELUsers. Perhaps there really aren't any complete EclipseLink/MongoDB/XML tutorials out there and if not, perhaps one of you good folks could help me with something strange. I am successfully persisting an Entity which has an Embeddable field in it, but all of the values of fields (primitive fields) get set to '{"#text": null}'. Example:

> db.WACTION.findOne()
{
    "_id" : ObjectId("51a573f73004703030fca204"),
    "wactionid" : {
        "#text" : null
    },
    "UUID" : {
        "uuid_clockSeqAndNode" : {
            "#text" : null
        },
        "uuid_time" : {
            "#text" : null
        }
    },
    "STATUS" : {
        "#text" : null
    },
    "TS" : {
        "#text" : null
    }
}

When I searched the internet for clues all I could find were references to XML processing or XML-JSON translation:


I'm not trying to move data from or to XML format so I don't even know if that is related to my problem. I know that the default DataFormatType for non-relational databases in EclipseLink is XML, so I made sure to set the "dataFormat":

<entity name="Waction" class="com.x.waction.Waction">
    <no-sql dataFormat="DataFormatType.MAPPED" />
    <attributes>
        <id name="id" />
    
        <basic name="mapKey">
            <column name="wactionid" nullable="false" />
            <access-methods get-method="getMapKeyString" set-method="setMapKeyString" />
        </basic>
        
        <basic name="ts" />
        <basic name="status" />
        <embedded name="uuid" />
        <embedded name="context" />
    </attributes>
</entity>

I'm a novice with EclipseLink so I might be missing something basic, but I also wonder if the XML mapping for "no-sql" might not correctly implement the "dataFormat" parameter.

Has anyone seen anything like this?

Nicholas




On Tue, May 28, 2013 at 2:50 PM, Nicholas Keene <nicholas@xxxxxxxxx> wrote:
Hello, ELUsers, I am new to the list. I'm tasked with using EclipseLink to persist into MongoDB using XML mappings. I've found some examples using annotations, such as this one, but none using XML mappings.


I've tried for a couple days now to turn my working XML mappings for relational databases into working mappings for MongoDB, but I can't get it right. I thought maybe you folks could help me find an example to start from.

Thanks!
Nicholas in Wisconsin



Back to the top