Search code examples
javahibernatedomain-driven-designnaming

how can hibernate entities be named differently from the domain entities?


how can hibernate entities be named differently from the domain entities? Since there are both domain entities and hibernate entities that have the same name (eg: organization, customer etc.) Is there a way by which the hibernate entities can be named in a way that communicates those are related to data layer?


Solution

  • You can use same name for domain entities and hibernate entities in different packages. But same package you cannot use same name. In that case you can use different name for hibernate entity classes. (Like OrganizationEntity, CustomerEntity) It is more visible and accessible.

    You should enter Correct table name within @Table(name="Customer") annotation.

    Example