4 Replies Latest reply on Nov 9, 2011 11:34 AM by tschleuss

    Entity name


      How can i discover entity name in seam 3 ?
      In seam 2 i do something like this:


      But i can't found this classe and methods in the new version.

        • 1. Re: Entity name

          What are you trying to do? I'm not sure what you are trying to do with this.

          That class is not in Seam 3, in fact, most of the classes from Seam 2 are not in Seam 3.

          • 2. Re: Entity name

            We have used this code to retrieve the entity name to make some queries.
            But i'm make a EntityUtils with some codes do replace seam 2 facilities :)
            I don't know if is the beast solution, but works.

                 public static String getEntityName(final Class<?> clazz) {
                      String name = null;
                      if (EntityUtils.isEntity(clazz)) {
                           Entity entity = clazz.getAnnotation(Entity.class);
                           if (!entity.name().isEmpty()) {
                                name = entity.name();
                           } else {
                                name = clazz.getName();
                      return name;

                 public static boolean isEntity(final Class<?> clazz) {
                      if (EntityUtils.isSerializable(clazz)) {
                           return clazz.isAnnotationPresent(Entity.class);
                      return false;

                 public static boolean isSerializable(final Class<?> clazz) {
                      if (clazz.getInterfaces() != null) {
                           for (Class<?> subClz : clazz.getInterfaces()) {
                                if (subClz == Serializable.class) {
                                     return true;
                      return (clazz.getSuperclass() != null) ? isSerializable(clazz
                                .getSuperclass()) : false;

            Thanks anyway.

            • 3. Re: Entity name

              Try this stackoverflow question for a better way to check for serializable. The rest look like they're okay. Take a look at the JPA 2.0 API Metamodel for some other ideas on how to test for some of the entity stuff you're looking for.

              • 4. Re: Entity name