Answer the question
In order to leave comments, you need to log in
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
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.
Read how JPA/Hibernate are
configured The config file either lists Entity classes or specifies a package
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 questionAsk a Question
731 491 924 answers to any question