P
P
pqgg7nwkd42016-11-10 12:23:32
Java
pqgg7nwkd4, 2016-11-10 12:23:32

How does JPA find all classes tagged with @Entity?

Good afternoon.
I want to write an analogue of JPA for educational purposes.
I use Tomcat, it has CDI (Weld) and Bean Validation (Hibernate).
Tell me how JPA (if I used it) would find classes with the @Entity annotation?
How does the same Weld find all classes?
I'm interested in the approach. Maybe Weld can help me with this?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Kosarev, 2016-11-10
@jaxtr

When configuring Hibernate / JPA, a list of @Entity classes is specified, or a base package, relative to which the search for classes marked with the @Entity annotation is performed. There is a SomeClass.class.isAnnotationPresent() method for this.
PS: IMHO, writing a JPA analog "for educational purposes" is not a good idea.

E
Evhen, 2016-11-10
@EugeneP2

Read how JPA/Hibernate are
configured The config file either lists Entity classes or specifies a package

S
Severus256, 2016-11-10
@severus256

Umm ... what's in the approach? The framework parses your classes and bumping into the @Entity annotation adds the class to the project's Entity's list :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question