List of usage examples for org.hibernate.type EntityType isReferenceToPrimaryKey
public boolean isReferenceToPrimaryKey()
From source file:org.seasar.hibernate.jpa.metadata.HibernateAttributeDesc.java
License:Apache License
/** * <code>value</code>????<code>allValues</code>????? * //from w w w . java 2s . c om * @param allValues * ?? * @param type * Hibernate? * @param value * ???????? */ protected void gatherAttributeValues(final List<Object> allValues, final Type type, final Object value) { if (value == null) { allValues.add(null); return; } if (!isReadTargetType(type)) { return; } if (type.isEntityType()) { final EntityType entityType = EntityType.class.cast(type); if (entityType.isReferenceToPrimaryKey()) { gatherIdAttributeValues(allValues, entityType, value); } else { final String name = entityType.getAssociatedEntityName(); final EntityPersister ep = factory.getEntityPersister(name); final Type[] subtypes = ep.getPropertyTypes(); final Object[] subvalue = ep.getPropertyValues(value, EntityMode.POJO); for (int i = 0; i < subtypes.length; i++) { gatherAttributeValues(allValues, subtypes[i], subvalue[i]); } } } else if (type.isComponentType()) { final AbstractComponentType componentType = AbstractComponentType.class.cast(type); final Object[] subvalues = componentType.getPropertyValues(value, EntityMode.POJO); final Type[] subtypes = componentType.getSubtypes(); for (int i = 0; i < subtypes.length; i++) { gatherAttributeValues(allValues, subtypes[i], subvalues[i]); } } else { allValues.add(convert(type, value)); } }