ifelse.codes
ifelse.codes

Reputation: 2389

Jhipster : How to generate code for list of Entity / Plural Entity

Let's say I have an entity Book I want Jhipster to generate a Books Entity something like

class Books{
  List<Book> books;
}

And Generate corresponding rest controllers like

Books saveAllBooks(Books books)
Books updateAllBooks(Books books)

Upvotes: 0

Views: 255

Answers (1)

Ga&#235;l Marziou
Ga&#235;l Marziou

Reputation: 16284

There's no need to create a Books entity if it contains only a list of Book entities, you could just add manually the list methods to generated REST controllerBookResource.java as you don't need any additional repository.

But if Books has other fields that you want to persist in database, you could generate 2 entities with one-to-many relationship. I wouldn't recommend using plural as it could probably conflict with other generated code.

entity Book{
   title String required
}

entity BookBatch{
    name String required
}

// RELATIONSHIPS:
relationship ManyToOne {
    Book to BookBatch
}

Upvotes: 1

Related Questions