project_mapping parent_project_id (foreign key to project table)
child_project_id (foreign key to project table)
I have a JPA entity
I would like to add mapping such that I can use the existing database tables as is and still map a parent-child relationship where by a project can be a parent to multiple other projects and can also be a child to at most one other project. So ultimately I need somewhere to have a mapping of a collection of projects to represent the child projects associated to a given project and a parentProjectId to hold the relationship of a parent to a given project is one exists.
I don't know if I can just map this directly in the Project entity or if I need to create a new ProjectMapping entity instead and do the mapping there and what the mappings should look like depending on where they are implemented. Is it possible to do this just in the Project entity?
there are 3 ways, you should decide which one to use-
- First one is to have a new field in Project class to have the Parent Project.
- Second option is to have a collection of Child Projects in the project class.
- Both of the above.
You just need to put proper annotations so that JPA uses your existing tables & columns. No change at all will be required on database side. Hope that answers.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com