Code Monkey home page Code Monkey logo

Comments (5)

guylabs avatar guylabs commented on July 23, 2024

Hi @bergacat1,

sorry for my delay but I was on a longer trip and now I am working partially.

Well if you do not have any property in the JSON which identifies the class B or C then not as in the JSON you cannot get the inheritance information of the Java classes.

You could just add an identifier to the class A which then would be different in class B or class C.

Does that answer your question?

Thanks and regards,

Guy

from angular-spring-data-rest.

bergacat1 avatar bergacat1 commented on July 23, 2024

But you can determine which is the class of every object in the JSON. In the previous example you can see the name "as" associated with the list of objects of class A, and the name "bs" associated with the list of objects of class B. If there were another class called "OtherClass", the name for the list of objects of this type would be "otherClasss".

from angular-spring-data-rest.

bergacat1 avatar bergacat1 commented on July 23, 2024

Related to this issue, I'm experimenting a problem which makes impossible to keep working with this module. I will explain the full use case so you can reproduce the problem.

I have a class "User" related with some "ExternalUsers":

public class User {
  ...
  @OneToMany(...)
  private List<ExternalUser> externalUsers;
  ...
}

The class "ExternalUser" is the super-class of "YouTubeChannel" and "GoogleUser", so the list of ExternalUsers in the User class can contain different types of objects.

The problem occurs when I use the user._resources('externalUsers').get() to obtain the list of ExternalUsers related with a user. The returning object only contains one ExternalUser object but the raw response from the server is the following:

{
  "_embedded" : {
    "googleUsers" : [ {
      "name" : "Albert Berga",
      "url" : "https://plus.google.com/107051416216090286883",
      "_links" : {
        "self" : {
          "href" : "http://10.50.54.194:8080/googleUsers/107051416216090286883"
        },
        "googleUser" : {
          "href" : "http://10.50.54.194:8080/googleUsers/107051416216090286883"
        },
        "youTubeChannels" : {
          "href" : "http://10.50.54.194:8080/googleUsers/107051416216090286883/youTubeChannels"
        },
        "User" : {
          "href" : "http://10.50.54.194:8080/googleUsers/107051416216090286883/User"
        }
      }
    } ],
    "youTubeChannels" : [ {
      "id" : "UCXKrFkh0t1KvtQJdg9NwTuQ",
      "name" : "Albert Berga",
      "url" : "http://www.youtube.com/channel/UCXKrFkh0t1KvtQJdg9NwTuQ",
      "_links" : {
        "self" : {
          "href" : "http://10.50.54.194:8080/youTubeChannels/UCXKrFkh0t1KvtQJdg9NwTuQ"
        },
        "youTubeChannel" : {
          "href" : "http://10.50.54.194:8080/youTubeChannels/UCXKrFkh0t1KvtQJdg9NwTuQ"
        },
        "googleUser" : {
          "href" : "http://10.50.54.194:8080/youTubeChannels/UCXKrFkh0t1KvtQJdg9NwTuQ/googleUser"
        },
        "User" : {
          "href" : "http://10.50.54.194:8080/youTubeChannels/UCXKrFkh0t1KvtQJdg9NwTuQ/User"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://10.50.54.194:8080/Users/68c54696-7fee-4082-9bce-86e1904ca925/externalUsers"
    }
  }
}

The YouTubeChannel object in the raw response is inaccessible using the angular-spring-data-rest module.

Thank you,

Albert

from angular-spring-data-rest.

bergacat1 avatar bergacat1 commented on July 23, 2024

I've just seen in the documentation that there is a configuration ("embeddedNamedResources") which prevents this behaviour. So it was my problem of don't look at the documentation.

Sorry for the disturbances.

from angular-spring-data-rest.

guylabs avatar guylabs commented on July 23, 2024

Hi @bergacat1

ok so everything is solved and you could address your problem yourself? I will close the issue for now and if there is anything else please reopen it.

Thanks and regards,

Guy

from angular-spring-data-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.