Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

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

$
0
0
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

Viewing all articles
Browse latest Browse all 297

Trending Articles