When using Hibernate with annotation, SecondaryTable needs to be used carefully while using the Discriminator. We assume that there is a table called Inventory which is the parent table that has common elements including Id, createDate, modifiedDate, SKU#, and productType. The other tables, which are children of the Inventory table, are TV_Inventory, DVD_inventory etc.. In this example, we consider TV_Inventory which inherits from Inventory (in terms of objects). @Entity @Table(name = "INVENTORY") @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "PRODUCT_TYPE", discriminatorType = DiscriminatorType.STRING, length = 20) @SequenceGenerator(name = "InventorySequence", sequenceName = "INV_SEQ", allocationSize = 1) public abstract class Inventory { // getters and setters with other annotations for the columns and relevant methods. } Consider the child object associated with the table TV_INVENTORY. The outli...
Focus on Mobile app tips for devices, introductory articles and technology articles on various topics. Please let us know what else you want to see on on this blog and we will post articles. We want you to be more efficient on your devices.