protected void validatePropertyName(String propertyName, String methodName) { if (persistentEntity == null) return; if (propertyName == null) { throw new IllegalArgumentException("Cannot use [" + methodName + "] restriction with null property name"); } PersistentProperty property = persistentEntity.getPropertyByName(propertyName); if (property == null && persistentEntity.getIdentity().getName().equals(propertyName)) { property = persistentEntity.getIdentity(); } if (property == null && !queryCreator.isSchemaless()) { throw new IllegalArgumentException("Property [" + propertyName + "] is not a valid property of class [" + persistentEntity + "]"); } }
private static void convertArgumentsForProp(PersistentEntity persistentEntity, PersistentProperty<?> prop, String propertyName, Object[] arguments, ConversionService conversionService) { if (prop == null) { if (propertyName.equals(persistentEntity.getIdentity().getName())) { prop = persistentEntity.getIdentity(); } } if (prop != null) { Class<?> type = prop.getType(); Collection<?> collection = (Collection<?>) arguments[0]; List<Object> converted; if(collection == null) { converted = Collections.emptyList(); } else { converted = new ArrayList<>(collection.size()); for (Object o : collection) { if (o != null && !type.isAssignableFrom(o.getClass())) { o = conversionService.convert(o, type); } converted.add(o); } } arguments[0] = converted; } } }
public List doInHibernate(org.hibernate.Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(type); hibernateTemplate.applySettings(criteria); return criteria.add( Restrictions.in(persistentEntity.getIdentity().getName(), getIterableAsCollection(keys))) .list(); } });
protected boolean isAssignedId(PersistentEntity persistentEntity) { boolean assignedId = false; PersistentProperty identity = persistentEntity.getIdentity(); if(identity != null) { PropertyMapping mapping = identity.getMapping(); if (mapping != null) { Property p = mapping.getMappedForm(); assignedId = p != null && "assigned".equals(p.getGenerator()); } } return assignedId; }
public void run() { updateToManyIndices(e, updateId, toManyKeys, false); if (doesRequirePropertyIndexing()) { toIndex.put(persistentEntity.getIdentity(), updateId); updatePropertyIndices(updateId, toIndex, toUnindex); } for (OneToMany inverseCollection : inverseCollectionUpdates.keySet()) { final Serializable primaryKey = inverseCollectionUpdates.get(inverseCollection); final NativeEntryEntityPersister inversePersister = (NativeEntryEntityPersister) session.getPersister(inverseCollection.getOwner()); final AssociationIndexer associationIndexer = inversePersister.getAssociationIndexer(e, inverseCollection); associationIndexer.index(primaryKey, updateId); } } };
public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
private static PersistentProperty validateProperty(PersistentEntity entity, String name, Class criterionType) { PersistentProperty identity = entity.getIdentity(); if (identity != null && identity.getName().equals(name)) { return identity; } PersistentProperty[] compositeIdentity = ((AbstractPersistentEntity) entity).getCompositeIdentity(); if(compositeIdentity != null) { for (PersistentProperty property : compositeIdentity) { if(property.getName().equals(name)) { return property; } } } PersistentProperty prop = entity.getPropertyByName(name); if (prop == null) { throw new InvalidDataAccessResourceUsageException("Cannot use [" + criterionType.getSimpleName() + "] criterion on non-existent property: " + name); } return prop; }
public int handle(PersistentEntity entity, Query.Criterion criterion, StringBuilder q, StringBuilder whereClause, String logicalName, int position, List parameters, ConversionService conversionService, boolean allowJoins, boolean hibernateCompatible) { Query.IdEquals eq = (Query.IdEquals) criterion; PersistentProperty prop = entity.getIdentity(); Class propType = prop.getType(); position = appendCriteriaForOperator(whereClause, logicalName, prop.getName(), position, "=", hibernateCompatible); parameters.add(conversionService.convert( eq.getValue(), propType )); return position; } });
if(keyIterator.hasNext()) { Serializable key = keyIterator.next(); key = (Serializable) mappingContext.getConversionService().convert( key, p.getPersistentEntity().getIdentity().getType() ); final Object next = retrievedMap.get(key); list.set(i, next);
public String[] getIdentifierName() { PersistentProperty identity = classMapping.getEntity().getIdentity(); String propertyName = identity != null ? identity.getMapping().getMappedForm().getName() : null; if(propertyName != null) { return new String[] { propertyName }; } else { return new String[] { IDENTITY_PROPERTY }; } }
protected Serializable convertIdIfNecessary(PersistentEntity entity, Serializable nativeKey) { PersistentProperty identity = entity.getIdentity(); return (Serializable) getMappingContext().getConversionService().convert( nativeKey, identity.getType()); }
.getPropertyByName(propertyName); if (prop == null) { if (propertyName.equals(persistentEntity.getIdentity().getName())) { prop = persistentEntity.getIdentity();
public Object retrieve(Class type, Serializable key) { if (key == null || type == null || NULL.equals(key)) { return null; } Persister persister = getPersister(type); if (persister == null) { throw new NonPersistentTypeException("Cannot retrieve object with key [" + key + "]. The class [" + type.getName() + "] is not a known persistent type."); } final PersistentEntity entity = ((EntityPersister)persister).getPersistentEntity(); if (entity != null) { final PersistentProperty identity = entity.getIdentity(); if(!identity.getType().isAssignableFrom(key.getClass())) { key = convertIdentityIfNecessasry(identity, key); } } if (key == null) { return null; } Object o = getInstanceCache(type).get(key); if (o == null) { o = persister.retrieve(key); if (o != null) { cacheObject(key, o); } } return o; }
@Override public Object getIdentifier() { String idName = getIdentifierName(persistentEntity.getMapping()); if (idName != null) { return getProperty(idName); } PersistentProperty identity = persistentEntity.getIdentity(); if(identity != null) { return getProperty(identity.getName()); } return null; }
PersistentProperty property = entity.getPropertyByName(name); if (property == null) { final PersistentProperty identity = entity.getIdentity(); if (name.equals(identity.getName())) { property = identity;
@SuppressWarnings("unchecked") public Object proxy(Serializable key) { PersistentEntity entity = getPersistentEntity(); PersistentProperty identity = entity.getIdentity(); if(identity != null) { key = (Serializable) mappingContext.getConversionService().convert(key, identity.getType()); } return getProxyFactory().createProxy(session, entity.getJavaClass(), key); }
@Override @SuppressWarnings("unchecked") public Object proxy(Serializable key) { PersistentEntity entity = getPersistentEntity(); PersistentProperty identity = entity.getIdentity(); if(identity != null) { key = (Serializable) getMappingContext().getConversionService().convert(key, identity.getType()); } return getProxyFactory().createProxy(session, entity.getJavaClass(), key); } }
if (currentGrailsProp.equals(domainClass.getIdentity())) continue; if (currentGrailsProp.getName().equals(GormProperties.VERSION)) continue;
!(grailsProperty instanceof Association) && !grailsProperty.equals(grailsProperty.getOwner().getIdentity());