Class JakartaCriteriaProcessor

  • All Implemented Interfaces:
    Processor

    @SupportedAnnotationTypes({"jakarta.persistence.Entity","jakarta.persistence.Embeddable","jakarta.persistence.MappedSuperclass"})
    public class JakartaCriteriaProcessor
    extends AbstractProcessor
    Annotation processor for Jakarta Persistence to generate "dummy" classes for all Entity classes for use with Criteria API. Any class ({MyClass}) that has a Jakarta Persistence "class" annotation will have a stub class ({MyClass}_) generated.
    • For each managed class X in package p, a metamodel class X_ in package p is created.
    • The name of the metamodel class is derived from the name of the managed class by appending "_" to the name of the managed class.
    • The metamodel class X_ must be annotated with the jakarta.persistence.StaticMetamodel annotation
    • If class X extends another class S, where S is the most derived managed class (i.e., entity or mapped superclass) extended by X, then class X_ must extend class S_, where S_ is the meta-model class created for S.
    • For every persistent non-collection-valued attribute y declared by class X, where the type of y is Y, the metamodel class must contain a declaration as follows:
      public static volatile SingularAttribute<X, Y> y;
    • For every persistent collection-valued attribute z declared by class X, where the element type of z is Z, the metamodel class must contain a declaration as follows:
      • if the collection type of z is java.util.Collection, then
        public static volatile CollectionAttribute<X, Z> z;
      • if the collection type of z is java.util.Set, then
        public static volatile SetAttribute<X, Z> z;
      • if the collection type of z is java.util.List, then
        public static volatile ListAttribute<X, Z> z;
      • if the collection type of z is java.util.Map, then
        public static volatile MapAttribute<X, K, Z> z;
        where K is the type of the key of the map in class X
    • Field Detail

      • annotationsWithTargetEntity

        protected static Class[] annotationsWithTargetEntity
    • Constructor Detail

      • JakartaCriteriaProcessor

        public JakartaCriteriaProcessor()
    • Method Detail

      • processClass

        protected void processClass​(TypeElement el)
        Handler for processing a Jakarta Persistence annotated class to create the criteria class stub.
        Parameters:
        el - The class element
      • getPersistentSupertype

        public TypeElement getPersistentSupertype​(TypeElement element)
        Method to find the next persistent supertype above this one.
        Parameters:
        element - The element
        Returns:
        Its next parent that is persistable (or null if no persistable predecessors)
      • getDefaultAccessMembers

        public static List<? extends Element> getDefaultAccessMembers​(TypeElement el)
        Convenience accessor for members for the default access type of the supplied type element. If properties are annotated then returns all properties, otherwise returns all fields.
        Parameters:
        el - The type element
        Returns:
        The members
      • isJakartaAnnotated

        public static boolean isJakartaAnnotated​(TypeElement el)
        Convenience method to return if this class element has any of the defining Jakarta Persistence annotations.
        Parameters:
        el - The class element
        Returns:
        Whether it is to be considered a Jakarta Persistence annotated class