iCrus
iCrus

Reputation: 1248

What is the use of @Entity annotation when entity not included in persistence unit

I have few JPA annotated entity classes in my sample application i am building and almost all are specified in the persistence unit to be managed by the JPA provider.

For those entity which are annotated but not included in the persistence.xml:

  1. What is the use of the entity annotation ?
  2. Do they still map to the tables in the database ?
  3. Since they are not managed by provider, how can i use those entities to persist data?

Appreciate any answers to clarify my understanding.

Upvotes: 2

Views: 10048

Answers (2)

Anders R. Bystrup
Anders R. Bystrup

Reputation: 16050

JPA will include any class annotated with @Entity in the persistence management setup. You don't need persistence.xmlif you use annotations.

Cheers,

Upvotes: 4

Petar Minchev
Petar Minchev

Reputation: 47373

JPA scans automatically for classes annotated with @Entity and includes them.

Upvotes: 1

Related Questions