Tabnine Logo
PersistentEntity.getIdentity
Code IndexAdd Tabnine to your IDE (free)

How to use
getIdentity
method
in
org.grails.datastore.mapping.model.PersistentEntity

Best Java code snippets using org.grails.datastore.mapping.model.PersistentEntity.getIdentity (Showing top 20 results out of 315)

origin: org.grails/grails-datastore-gorm

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 + "]");
  }
}
origin: org.grails/grails-datastore-gorm

  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;
    }
  }
}
origin: org.grails/grails-hibernate

  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();
  }
});
origin: org.grails/grails-datastore-core

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;
}
origin: org.grails/grails-datastore-core

  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);
    }
  }
};
origin: org.grails/grails-datastore-core

  public Property getMappedForm() {
    return classMapping.getEntity().getIdentity().getMapping().getMappedForm();
  }
};
origin: org.grails/grails-datastore-core

  public Property getMappedForm() {
    return classMapping.getEntity().getIdentity().getMapping().getMappedForm();
  }
};
origin: org.grails/grails-datastore-core

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;
}
origin: org.grails/grails-datastore-core

  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;
  }
});
origin: org.grails/grails-datastore-core

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);
origin: org.grails/grails-datastore-core

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 };
  }
}
origin: org.grails/grails-datastore-core

protected Serializable convertIdIfNecessary(PersistentEntity entity, Serializable nativeKey) {
  PersistentProperty identity = entity.getIdentity();
  return (Serializable) getMappingContext().getConversionService().convert(
      nativeKey, identity.getType());
}
origin: org.grails/grails-datastore-gorm

    .getPropertyByName(propertyName);
if (prop == null) {
  if (propertyName.equals(persistentEntity.getIdentity().getName())) {
    prop = persistentEntity.getIdentity();
origin: org.grails/grails-datastore-core

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;
}
origin: org.grails/grails-datastore-core

@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;
}
origin: org.grails/grails-datastore-core

PersistentProperty property = entity.getPropertyByName(name);
if (property == null) {
  final PersistentProperty identity = entity.getIdentity();
  if (name.equals(identity.getName())) {
    property = identity;
origin: org.grails/grails-datastore-core

@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);
}
origin: org.grails/grails-datastore-core

  @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);
  }
}
origin: org.grails/grails-datastore-gorm-hibernate-core

if (currentGrailsProp.equals(domainClass.getIdentity())) continue;
if (currentGrailsProp.getName().equals(GormProperties.VERSION)) continue;
origin: org.grails/grails-datastore-gorm-hibernate-core

!(grailsProperty instanceof Association) && !grailsProperty.equals(grailsProperty.getOwner().getIdentity());
org.grails.datastore.mapping.modelPersistentEntitygetIdentity

Javadoc

Returns the identity of the instance

Popular methods of PersistentEntity

  • getJavaClass
  • getMapping
    Defines the mapping between this persistent entity and an external form
  • getPropertyByName
    Obtains a PersistentProperty instance by name
  • getName
    The entity name including any package prefix
  • getPersistentProperties
    A list of properties to be persisted
  • getVersion
    Returns the version property.
  • isMultiTenant
  • getAssociations
    A list of the associations for this entity. This is typically a subset of the list returned by #getP
  • getCompositeIdentity
    The composite id
  • getMappingContext
    Obtains the MappingContext where this PersistentEntity is defined
  • getReflector
  • getTenantId
  • getReflector,
  • getTenantId,
  • isInitialized,
  • isOwningEntity,
  • isRoot,
  • isVersioned,
  • addOwner,
  • getDecapitalizedName,
  • getDiscriminator

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • Kernel (java.awt.image)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now