Announcement Announcement Module
No announcement yet.
Inserting Embedded document data Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inserting Embedded document data

    I am new to spring-data and just trying to understand the best way to get things done. Assume I have a collection called Artist, and with in I have a list of Albums, something like this:

    public class Artist {
    String artistId;
    String name;
    List<Album> albums;

    if I want to add an album to this artist what is the best way to do this? Should I first find the artist, add to the list and then save the artist?

    Artist a=artistRepo.findByName("thename");
    a.getAlbums().add(new Album());;

    or is there a more efficient way to do this?