0

I'm having trouble creating a model for a couple entities that is sane in both Hibernate and the Database. Any help is appreciated.

A company entity and table exists, which provides both a company name and a "company code". The company code must be unique.

Company's may act as 2 different entities, clients or partners.

We'd like to have separate Client and Partner Entities.

The complicating factors I see are

1) Companies can be both a client and a partner.

2) The company code must remain unique.

3) We want to be able to create new clients and partners passing company_code's as a parameter. eg. new Client("WALMART") and new Partner("WALMART") that should map to the same company.

Single-Table and Multi-Table Inheritance don't work because they don't map a Merchant and Client with the same company code to a single company.

Thanks all.

1 Answer 1

2

Could you have a Company table that the Partner and Client entities have a many-to-one link to? This would allow you to set the company on the partner and client as a descriptor (more of a has-a, although it is closer to a typing) without needing inheritance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.