Announcement Announcement Module
Collapse
No announcement yet.
MongoDB @Field Inconsistent - Bug? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoDB @Field Inconsistent - Bug?

    Hi,

    I am using Spring Data with MongoDB. It works very well. However, I'm seeing a bit of an anomaly.

    I have an object:

    Code:
    @Data public class BillingCodesOwner {
    	
    	@Field("oid")
    	private String ownerId;
    	@Field("oln")
    	private String ownerLastName;
    	@Field("ofn")
    	private String ownerFirstName;
    	@Field("ost")
    	private BillingCodesState ownerState;
    	@Field("odt")
    	private Date ownershipDate;
    	
    }
    This object is in a collection that is part of a bean hierarchy that gets persisted into MongoDB. It appears as though the @Field annotation is being ignored on occasion.

    Code:
    				"ost" : [
    					{
    						"ownerId" : null,
    						"ownerFirstName" : null,
    						"ownerLastName" : null,
    						"ownershipDate" : null,
    						"ownerState" : "UNASSIGNED"
    					},
    					{
    						"ownerId" : "51303e8cda06ab8bb3832b82",
    						"ownerFirstName" : "Tod",
    						"ownerLastName" : "Antilla",
    						"ownershipDate" : ISODate("2013-03-06T01:13:35.127Z"),
    						"ownerState" : "ASSIGNED"
    					},
    					{
    						"oid" : "51303e8cda06ab8bb3832b82",
    						"oln" : "Antilla",
    						"ofn" : "Tod",
    						"ost" : "CODED",
    						"odt" : ISODate("2013-03-06T01:13:54.796Z")
    					}
    				],
    As you can see, the bottom entry has the @Field identifiers, where the top two do not.

    These are persisted exactly the same way, however, the bean graph having the first two entries went to the client and came back before being persisted. Why would serializing/deserializing and sending this to an ActionScript client ignore the @Field annotations? My impression was that the @Field annotations were checked every time these beans are persisted. Is that not true?

    Thanks,
    Tom

  • #2
    The document you showed doesn't really match the code you showed:

    1. ownerState is of type BillingCodesState, in your document it is an array. how does that work together?
    2. of what type are the nested documents in the ost field in the document?
    3. Is it possible that the different elements were inserted in different ways (object insertion VS. using DBObjects directly)?

    So we essentially need to know quite a few additional things:

    1. What is the ost field in the document actually showing. Given the questions above it doesn't seem to be the ownerState field of the shown class?
    2. What does BillingCodesState look like?
    3. What does your client code look like (esp. document manipulations)

    Comment


    • #3
      Hi Oliver,

      Here is some more information.

      The BillingCodesOwner object is part of a significant bean graph. I just included the part of the bean graph that was affected. Here is the hierarchy:

      Code:
      public class Chart implements Serializable {
      
      	@Id
      	private ObjectId id;
      	
              ...  LOTS OF OTHER FIELDS HERE - REMOVED FOR SECURITY ...
      
      	@Field("cl")
      	private Map<ChartState, List<IChartChild>> childList = null;
      	
      }
      In the part of the bean graph we're looking at, the array of List<IChartChild> has an array of the following object:

      Code:
      @Data public class BillingCodes implements IChartChild, Serializable {
      
             .... FIELDS REMOVED FOR SECURITY ...
      	
      	@Field("ost")
      	private Stack<BillingCodesOwner> ownerStack;
      	
      }
      In the stack, which is field "ost", you have BillingCodesOwner objects. In order to persist, we persist the top-level object, Chart.

      Code:
      chart = chartRepo.save(chart);
      Let me know if that helps.

      Tom

      Comment

      Working...
      X