I've seen a lot of information on the different inheritance strategies but can't seem to find anything on how you setup a REST controller when using a single table strategy. In my scenario, I have 2 Barcode types: product and case.
I created a Barcode superclass that ProductBarcode and CaseBarcode inherit from. However, I have the following questions regarding how to implement this:
- Do I need separate repositories for ProductBarcode and CaseBarcode?
- Can I use a single endpoint to create/update/delete both kinds of Barcodes?
I have another entity (Product) that relates to Barcode and needs to be able to get the details for a barcode based on an ID. Product won't know what type of Barcode the ID belongs to. Is this something that will cause an issue?
To summarize what I'm trying to do:
- Create a barcode entry of either ProductBarcode or CaseBarcode by sending a JSON POST request to a single endpoint such as localhost:8080/barcodes.
- Retrieve or update a barcode of either type from a single endpoint.
- Be able to perform CRUD operations without needing to know which type of Barcode is being operated on.
Is this something that is doable using Spring Data JPA and Hibernate? Thanks for any advice.