I could create an ApproignItem table for each entity type (e.g. A_ApprovalItem, B_ApprovalItem, etc.). This seems like a good database side schema.
But
It seems I need to create separate domain classes in Java for each entity statement (e.g. AAprrovalItem class, BApprovalItem class, etc.).
You do not need it. you can create one class ApprovedItem and create the @OneToMany relationship between the parent classes and your statement. Hibernate takes care of creating a linked table for each relationship.
@Entity public class ClassA { @Id @GeneratedValue private Integer id;
And your class is ApprovalItem
@Entity public class ApprovalItem { @Id @GeneratedValue private Integer id;
But let's see what Java Persistence with Hibernate says.
You may have shared links for Bid objects. As suggested earlier, a user can have a set of links to the Bid instances they made. You cannot delete an item and all its bids without deleting these links in the first place. You may get an exception if you try to complete a transaction , because the foreign key constraint may be violated .
Therefore, keep this in mind when working with shared links.
To see what the target diagram looks like, you can use the following
AnnotationConfiguration configuration = new AnnotationConfiguration(); configuration .addAnnotatedClass(ClassA.class) .addAnnotatedClass(ClassB.class) .addAnnotatedClass(ApprovalItem.class) .setProperty(Environment.USER, <TYPE_YOUR_USER>) .setProperty(Environment.PASS, <TYPE_YOUR_PASSWORD>) .setProperty(Environment.URL, <TYPE_YOUR_URL>) .setProperty(Environment.DIALECT, <TYPE_YOUR_DIALECT>) .setProperty(Environment.DRIVER, <TYPE_YOUR_DRIVER>); SchemaExport schema = new SchemaExport(configuration); schema.setOutputFile("schema.sql"); schema.create(<DO_YOU_WANT_TO_PRINT_TO_THE_CONSOLE>, <DO_YOU_WANT_TO_EXPORT_THE_SCRIPT_TO_THE_DATABASE>);
It will generate a file called schema.sql that contains the target schema.
Respectfully,