I have base entity
@MappedSuperclass
@EntityListeners({AuditingEntityListener.class})
public class BaseAuditEntity extends BaseEntity {
...
}
and the entity below
package core.entities
@Entity
public class Customer extends BaseAuditEntity {
...
}
when I try to query database using criteria builder like below:
CriteriaQuery<BaseIdCodeDto> query =
getCriteriaBuilder().createQuery(BaseIdCodeDto.class);
Root<Customer> root = query.from(Customer.class);
it says:
org.springframework.dao.InvalidDataAccessApiUsageException: Not an
entity: class core.entities.Customer; nested exception is
java.lang.IllegalArgumentException: Not an entity:
I dont have a persistence.xml file. I know that other projects are working without this file so how can I fix this? What is the problem?
Customer class is located in another project. I add maven dependency to the pom of the current project. The problem could be this, but I have no solution.
I created Customer class in my current project. The error changed. This time it does not see one to one depended entities like CustomerChannel. This class is also located in the depended project and also annotated with @Entity as well. So why doesn't spring boot see it? I expect all the classes annotated with the @Entity should be registered as entities, but spring boot does not register entities in the depended projects. Am I wrong to expect this?
It says
Customer.customerChannel references an unknown entity:
core.entities.CustomerChannel
It looks like if I add all of the entities from the depended project to the current project, the problem will be fixed but I cant do it because there are multiple projects using the same entities.
Any help would be appreciated.