/** * Returns the class of an entity bean instance * * @param bean * The entity bean instance * @return The class of the entity bean */ public Class getBeanClass(Object bean) { return Entity.forBean(bean).getBeanClass(); }
/** * Returns the class of an entity bean instance * * @param bean The entity bean instance * @return The class of the entity bean */ public Class getBeanClass(Object bean) { return Entity.forClass(bean.getClass()).getBeanClass(); }
public Object getIdentifier(Object entity) { if (identifierGetter != null) { return Reflections.invokeAndWrap(identifierGetter, entity); } else if (identifierField != null) { return Reflections.getAndWrap(identifierField, entity); } else { throw new IllegalStateException("@Id attribute not found for entity class: " + getBeanClass().getName()); } }
public static Class getEntityClass(Object bean) { Class clazz = null; try { clazz = Entity.forBean(bean).getBeanClass(); } catch (NotEntityException e) { // It's ok, try some other methods } if (clazz == null) { clazz = Hibernate.getClass(bean); } return clazz; }
private void mergeAnnotationAndOrmXml(EjbEntityDescriptor descriptor) this.name = lookupName(getBeanClass(), descriptor); if (this.name == null) throw new NotEntityException("Unable to establish name of entity " + getBeanClass()); this.preRemoveMethod = getEntityCallbackMethod(getBeanClass(), descriptor.getPreRemoveMethodName()); this.prePersistMethod = getEntityCallbackMethod(getBeanClass(), descriptor.getPrePersistMethodName()); this.preUpdateMethod = getEntityCallbackMethod(getBeanClass(), descriptor.getPreUpdateMethodName()); this.postLoadMethod = getEntityCallbackMethod(getBeanClass(), descriptor.getPostLoadMethodName()); this.identifierField = descriptor.getIdentifierFieldName() != null ? Reflections.getField(getBeanClass(), descriptor.getIdentifierFieldName()) : null; this.identifierGetter = descriptor.getIdentifierPropertyName() != null ? Reflections.getGetterMethod(getBeanClass(), descriptor.getIdentifierPropertyName()) : null; this.versionField = descriptor.getVersionFieldName() != null ? Reflections.getField(getBeanClass(), descriptor.getVersionFieldName()) : null; this.versionGetter = descriptor.getVersionPropertyName() != null ? Reflections.getGetterMethod(getBeanClass(), descriptor.getVersionPropertyName()) : null; for ( Class<?> clazz=getBeanClass(); clazz!=Object.class; clazz = clazz.getSuperclass() )