Answer the question
In order to leave comments, you need to log in
Spring Data Rest. How can I force the categoryId for a OneToMany relationship to be output when a GET_ONE request is made?
Kotlin code:
@Entity data class Page(
val name: String,
@OneToMany val category: Category,
@Id @GeneratedValue val id: Int = -1
)
@Entity data class Category(
val name: String,
@Id @GeneratedValue val id: Int = -1
)
@RepositoryRestResource(collectionResourceRel = "pages", path="pages")
interface PageRepository : PagingAndSortingRepository<Page, Int>
@Value("#{target.category?.id}")
fun getCategoryId(): Int
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question