private EntityType introspectEntityType(Class type, EntityType parentType) throws SQLException { getInternalEntityConfig(type, _annotationCfg); Entity entityAnn = (Entity) _annotationCfg.getAnnotation(); EntityConfig entityConfig = _annotationCfg.getEntityConfig(); boolean isEntity = !_annotationCfg.isNull(); if (!isEntity) return null; EntityType entityType; String typeName; if (entityConfig != null) typeName = entityConfig.getClassName(); else typeName = entityAnn.name(); // Validates the type String entityName; Inheritance inheritanceAnn = null; InheritanceConfig inheritanceConfig = null; Class rootClass = type; Entity rootEntityAnn = null; EntityConfig rootEntityConfig = null; validateType(type, true); // jpa/0ge2 // if (hasInheritance) { if (entityConfig == null) entityName = entityAnn.name(); else { entityName = entityConfig.getClassName(); int p = entityName.lastIndexOf('.'); if (p > 0) entityName = entityName.substring(p + 1); } if ((entityName == null) || "".equals(entityName)) { entityName = type.getSimpleName(); } entityType = _persistenceUnit.createEntity(entityName, type); _configManager.addType(type, new EntityConfig(type.getName(), this, entityType)); boolean isField = isField(type, entityConfig, false); if (isField) entityType.setFieldAccess(true); return entityType; }
private void introspectAttributeOverrides(EntityType entityType, Class type) { EntityType parent = entityType.getParentType(); if (parent == null) return; boolean isAbstract = Modifier.isAbstract(parent.getBeanClass().getModifiers()); if (parent.isEntity() && !isAbstract) return; HashMap<String, ColumnConfig> overrideMap = new HashMap<String, ColumnConfig>(); getInternalAttributeOverrideConfig(type, _annotationCfg); AttributeOverride attributeOverrideAnn = (AttributeOverride) _annotationCfg.getAnnotation(); boolean hasAttributeOverride = (attributeOverrideAnn != null); AttributeOverrides attributeOverridesAnn = (AttributeOverrides) type.getAnnotation(AttributeOverrides.class); ArrayList<AttributeOverrideConfig> attributeOverrideList = null; EntityConfig entityConfig = getEntityConfig(type.getName()); if (entityConfig != null) attributeOverrideList = entityConfig.getAttributeOverrideList(); boolean hasAttributeOverrides = false; if ((attributeOverrideList != null) && (attributeOverrideList.size() > 0)) { hasAttributeOverrides = true; } else if (attributeOverridesAnn != null) hasAttributeOverrides = true; if (hasAttributeOverride && hasAttributeOverrides) throw new ConfigException( L.l("{0} may not have both @AttributeOverride and @AttributeOverrides", type)); if (attributeOverrideList == null) attributeOverrideList = new ArrayList<AttributeOverrideConfig>(); if (hasAttributeOverride) { // Convert annotation to configuration. AttributeOverrideConfig attOverrideConfig = convertAttributeOverrideAnnotationToConfig(attributeOverrideAnn); attributeOverrideList.add(attOverrideConfig); } else if (hasAttributeOverrides) { if (attributeOverrideList.size() > 0) { // OK: attributeOverrideList came from orm.xml } else { // Convert annotations to configurations. AttributeOverride attOverridesAnn[] = attributeOverridesAnn.value(); AttributeOverrideConfig attOverrideConfig; /* XXX: for (int i = 0; i < attOverridesAnn.length; i++) { attOverrideConfig = convertAttributeOverrideAnnotationToConfig((JAnnotation) attOverridesAnn[i]); attributeOverrideList.add(attOverrideConfig); } * */ } } for (AttributeOverrideConfig override : attributeOverrideList) { overrideMap.put(override.getName(), override.getColumn()); } _depCompletions.add(new AttributeOverrideCompletion(this, entityType, type, overrideMap)); }