Generating One Class from Multiple Entities

Hello everybody,

My coworkers and I have created a very large entity relationship diagram to generate the tables in our SQL Server DB with. They have asked me to figure out how we can generate O/R Mapping XML (Specifically Hibernate hbm.xml files) and Java binary code files that combine several of those entities into a smaller amount of objects. For instance, we will have tables of accountType’s officeId’s and several other entities that are all just attributes of one object called “Account”.

I think what I need to know is how to model the entity relationship diagram so that when generate java binary code files they know the logical grouping of how tables as attributes versus tables as actual objects.

If anybody can explain the best way to go about this to me, I’d be very thankful, if of course it is do-able in VP 5.3

Thanks in advance,
Michael Pasacrita

Hi MPasacrita,

Sorry, but I’m afraid I don’t catch your meaning. Would you mind showing your need with several ERDs? Thank you.

Best Regards,

I am going to create an ERD with tables for Employee, Address, Phone Number, etc… Some with one to many relationships. I.E. An employee may have many phone number entries in that table. I will then create a class diagram with classes such as Employee, Address, Phone Number, and then I want to generate java byte code and hibernate mapping documents that show the employee having attributes as Lists/Bags (in Java/Hibernate) with that one to many relationship to those phone numbers. From what I’ve now read in the documentation I think it’s do-able, but I can’t seem to accomplish this. My problem thus far is this:

I created a simple ERD with three entities and used the “Send To”>“ORM Diagram” function because I want to generate, not only java byte code, but the Hibernate XML as well. I also manually created a class diagram that in my opinion is an exact duplicate of the ERD. I am trying to “Generate Code…” but I get errors instead. One is that it is telling me one of my classes does not have a primary key. In the other two diagrams, it does have a primary key, but I do not know how to specify that in the Class diagram, if I even need to do so. Also, it is saying that all three of my Classes are not synchronized to the ERD. I do not see the differences but if anybody wants I can attach the project document to this thread so that somebody can hopefully tell me what is not synchronized between my class diagram and my ERD. I am just looking to export POJO’s that show collection attributes will export, mapping directly to the one to many relationship of the tables. Thank you for the help again.

Mike Pasacrita

Hi Michael,

You can set the the collection type (List/Bags…) from the association specification dialog box (right-click on the association, select Open Specification… from the popup menu).

With regards to the error, you need to synchronize the ERD to class diagram (right-click on the ERD and select Synchronize to Class Diagram from the popup menu)

Best regards,