Announcement Announcement Module
Collapse
No announcement yet.
Spring Data REST Export @Entity and related n:n data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data REST Export @Entity and related n:n data

    Hi all,

    Sorry for the newbee question, but i can't find examples exporting a JPA entity with all the data asociated with this entity as a REL ...

    I have a n:n relation mapped with JPA and this WebApplicationInitializer:

    @Configuration
    public class BaseWebApplicationInitializer implements WebApplicationInitializer
    {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException
    {
    AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
    rootCtx.register(ApplicationConfig.class);

    servletContext.addListener(new ContextLoaderListener(rootCtx));

    ServletRegistration.Dynamic reg = servletContext.addServlet("rest-exporter", RepositoryRestDispatcherServlet.class);
    reg.setLoadOnStartup(1);
    reg.addMapping("/*");
    }
    }

    I have tried to export the data through REST using a PagingAndSortingRepository, but i only get a SELF link and no related data is exported:

    @RestResource(exported = true, rel = "simples", path = "simples")
    public interface SimpleRepository extends PagingAndSortingRepository<Uno, Integer>
    {
    }

    I also tried to define the ralations as EAGER without success:

    @OneToMany(mappedBy = "unoByUnoId", cascade = CascadeType.ALL, fetch = FetchType.EAGER)

    Any ideas??

    Best regards,
    Ricardo

  • #2
    Solved
    It was my fault defining the relations ...

    Comment

    Working...
    X