55068

Is it possible to use @XmlInverseReference where object and property are of same type?

I'm using the MOXy JAXB implementation and make quite extensive use of the @XmlInverseReference annotation. However, I've recently encountered a scenario where this approach doesn't seem to work. If I have a class containing a field with a property that's the same type as the parent class, applying @XmlInverseReference seems to suppress the marshalling of that property altogether. Omitting the annotation yields a predictable StackoverflowException.

Has anybody encountered this problem and discovered an effective solution with MOXy?

A quick sample of the offending class:

public class Person { private Long id; private Person spouse; public Long getId() { return id; } public void setId(Long id) { this.id = id; } @XmlInverseReference(mappedBy="spouse") public Person getSpouse() { return spouse; } public Person setSpouse(Person spouse) { this.spouse = spouse; } }

Answer1:

<strong>EclipseLink MOXy</strong>'s @XmlInverseReference can be used when the object and property are of the same type. The current problem with this use case is that the same property needs to be used for both directions of the relationship.

<strong>What Your Seeing</strong>

When a property is annotated with @XmlInverseReference, for marshalling MOXy will treat that property as being @XmlTransient.

<strong>Enhancement Request</strong>

I have entered the following enhancement request to support this type of behaviour. Please add any additional details that you feel are relevant.

Recommend

  • find a control by id from Dynamically added Template field in GridView
  • How and when is Font disposed for WinForms controls
  • Given a 4-5-4 calendar and a date, how do I determine what fiscal week that date falls in?
  • How to make all the rows of a table the same height as the biggest one
  • Does OpenCL allow concurrent writes to same memory address?
  • Determining signed state for HDF5 variables in NetCDF
  • Is it possible to run a playbook in “pull mode”?
  • Why would you want to use composition in golang?
  • Deploying a sample Spring Web MVC project
  • SMT prover yields 'unknown' despite strong proven assertions
  • Render QGraphicsScene according to zoom level
  • Application.AddMessageFilter - how to read exactly what keys were pushed?
  • Using recursion to search all combinations of elements in an array of integers
  • After Installing PMD in Luna in Prespective it is Not Showing?
  • Implementing “Add to Home Screen”, ala Safari
  • Bundler using old version
  • Per Machine App Registration
  • Quickly or concisely determine the longest string per column in a row-based data collection
  • Use neo4j server instead of embedded mode
  • GitHub default README markup
  • Change device language on Android 6.0 (Android M)
  • Invert string in Rust
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • Avoid registering duplicate broadcast receivers in Android
  • How to autopopulate a field in SugarCRM form
  • JqueryMobile Popup menu is not working
  • Reading a file into a multidimensional array
  • Android application: how to use the camera and grab the image bytes?
  • How to clear text inside text field when radio button is select
  • Scrapy recursive link crawler
  • Fetching methods from BroadcastReceiver to update UI
  • Excel - Autoshape get it's name from cell (value)
  • Check if a string to interpolate provides expected placeholders
  • Running a C# exe file
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • RestKit - RKRequestDelegate does not exist
  • Traverse Array and Display in markup
  • Converting MP3 duration time