Package javax.persistence

Examples of javax.persistence.Entity


    static final class EntityProcessor implements AnnotationProcessor {

        public void onStartElement(
                AnnotatedElement element,
                AnnotationProcessorStack context) {
            Entity entityAnnotation = element.getAnnotation(Entity.class);

            JpaEntity entity = new JpaEntity();
            entity.setClassName(((Class<?>) element).getName());
            entity.setAttributes(new JpaAttributes());

            if (!Util.isEmptyString(entityAnnotation.name())) {
                entity.setName(entityAnnotation.name());
            }

            context.push(entity);
        }
View Full Code Here


        // find / create metadata
        ClassMetaData meta = (m == null) ? getMetaData() : m;
        if (meta == null)
            return null;

        Entity entity = _cls.getAnnotation(Entity.class);
        MappedSuperclass mapped = _cls.getAnnotation(MappedSuperclass.class);
        Embeddable embeddable = _cls.getAnnotation(Embeddable.class);
        if (isMetaDataMode()) {
            meta.setAbstract(mapped != null);
            if (embeddable != null) meta.setEmbeddable();
            // while the spec only provides for embedded exclusive, it doesn't
            // seem hard to support otherwise
            if (entity == null)
                meta.setEmbeddedOnly(true);
            else {
                meta.setEmbeddedOnly(false);
                if (!StringUtils.isEmpty(entity.name()))
                    meta.setTypeAlias(entity.name());
            }
        }

        // track fetch groups to parse them after fields, since they
        // rely on field metadata
View Full Code Here

        return query;
    }

    @SuppressWarnings("unchecked")
    private static String getEntityName(Class clazz) {       
        Entity entity = (Entity) clazz.getAnnotation(Entity.class);

        if (entity == null || entity.name() == null || entity.name().length() == 0) {
            return clazz.getSimpleName();
        } else {
            return entity.name();
        }
    }
View Full Code Here

        }
    };

    private static Field[] getFields(Object object) {
        Class<?> objectClass = object.getClass();
        Entity entityAnnotation = objectClass.getAnnotation(Entity.class);

        List<Field> serializableFields;
        if (entityAnnotation == null) {
            serializableFields = getNonEntityFieldList(object);
        } else {
View Full Code Here

        return serializableFields;
    }

    private static List<Field> getEntityFieldList(Object entity) {
        Class<?> entityClass = entity.getClass();
        Entity entityAnnotation = entityClass.getAnnotation(Entity.class);
        if (entityAnnotation == null) {
            throw new IllegalArgumentException("EntitySerializer only introspects objects annotated with @Entity ");
        }

        List<Field> serializableFields = new ArrayList<Field>();
View Full Code Here

    static final class EntityProcessor implements AnnotationProcessor {

        public void onStartElement(
                AnnotatedElement element,
                AnnotationProcessorStack context) {
            Entity entityAnnotation = element.getAnnotation(Entity.class);

            JpaEntity entity = new JpaEntity();
            entity.setClassName(((Class<?>) element).getName());
            entity.setAttributes(new JpaAttributes());

            if (!Util.isEmptyString(entityAnnotation.name())) {
                entity.setName(entityAnnotation.name());
            }

            context.push(entity);
        }
View Full Code Here

        return descriptor.getPropertyType().getSimpleName();
    }


    public static String getEntityName(Class<?> aType) {
    Entity entity = (Entity) aType.getAnnotation(Entity.class);
    if (entity == null) {
      return aType.getSimpleName();
    }
    String entityName = entity.name();

    if (entityName == null) {
      return aType.getSimpleName();
    } else if (!(entityName.length() > 0)) {
      return aType.getSimpleName();
View Full Code Here

        }
      }
    }
  }
  public static String getEntityName(Class<?> aType) {
    Entity entity = aType.getAnnotation(Entity.class);
    if (entity == null) {
      return aType.getSimpleName();
    }
    String entityName = entity.name();

    if (entityName == null) {
      return aType.getSimpleName();
    } else if (!(entityName.length() > 0)) {
      return aType.getSimpleName();
View Full Code Here

  /**
   * Determine if this is an EJB3 annotated entity class.
   */
  private boolean isAnnotatedEntityClass(Class clazz)
      throws SpeedoException {
    Entity e = (Entity) clazz.getAnnotation(Entity.class);
    return (e != null);
  }
View Full Code Here

   * @param sc  The SpeedoClass to be constructed.
   * @throws SpeedoException
   */
  private void parseEntityClass(Class c, SpeedoClass sc)
      throws SpeedoException {
    Entity e = (Entity) c.getAnnotation(Entity.class);
    if (e == null) { // This is not an Entity class
      throw new SpeedoException(c.getName()
          + ": should be an annotated EJB3 entity class!");
    }
    logger.log(BasicLevel.DEBUG, "Parse annotation of class: "
        + c.getName());
    // name of the Entity when used in a query
    sc.nameForQuery = e.name();
    // kind of access to persistent information (variables ou
    // accessors)
    for (Class itf : c.getInterfaces()) {
      if (itf == Serializable.class) {
        sc.isSerializable = true;
View Full Code Here

TOP

Related Classes of javax.persistence.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.