/** * Adds the singular attribute. * * @param attributeName * the attribute name * @param attribute * the attribute */ public void addSingularAttribute(String attributeName, SingularAttribute<X, ?> attribute) { if (declaredSingluarAttribs == null) { declaredSingluarAttribs = new HashMap<String, SingularAttribute<X, ?>>(); } declaredSingluarAttribs.put(attributeName, attribute); onValidateAttributeConstraints((Field) attribute.getJavaMember()); onEmbeddableAttribute((Field) attribute.getJavaMember()); }
/** * Adds the id attribute. * * @param idAttribute * the id attribute * @param isIdClass * the is id class * @param idClassAttributes * the id class attributes */ public void addIdAttribute(SingularAttribute<? super X, ?> idAttribute, boolean isIdClass, Set<SingularAttribute<? super X, ?>> idClassAttributes) { this.idAttribute = idAttribute; this.isIdClass = isIdClass; this.idClassAttributes = idClassAttributes; if (MetadataUtils.onCheckValidationConstraints((Field) idAttribute.getJavaMember())) { this.hasValidationConstraints = true; } }
/** * Gets the data type. * * @param entityMetadata * the entity metadata * @param arg1 * the arg1 * @return the data type * @throws PropertyAccessException * the property access exception */ private Object[] getDataType(EntityMetadata entityMetadata, Object... arg1) throws PropertyAccessException { Field idField = (Field) entityMetadata.getIdAttribute().getJavaMember(); PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(idField); Object[] pKeys = new Object[arg1.length]; int cnt = 0; for (Object r : arg1) { pKeys[cnt++] = accessor.fromString(idField.getClass(), r.toString()); } return pKeys; }
private void processGeneratedValueAnnotation(Class<?> clazz, String persistenceUnit, EntityMetadata m, Map<String, IdDiscriptor> entityNameToKeyDiscriptorMap) { GeneratedValueProcessor processer = new GeneratedValueProcessor(); String pu = m.getPersistenceUnit(); String clientFactoryName = getClientFactoryName(persistenceUnit); if (pu != null && pu.equals(persistenceUnit) || clientFactoryName.equalsIgnoreCase("com.impetus.client.rdbms.RDBMSClientFactory")) { Field f = (Field) m.getIdAttribute().getJavaMember(); if (f.isAnnotationPresent(GeneratedValue.class)) { processer.process(clazz, f, m, entityNameToKeyDiscriptorMap); } } }
PropertyAccessorFactory.getPropertyAccessor((Field) entityMetadata.getIdAttribute().getJavaMember());
/** * Sets Primary Key (Row key) into entity field that was annotated with @Id. * * @param entity * the entity * @param metadata * the metadata * @param rowKey * the row key * @throws PropertyAccessException * the property access exception */ public static void setId(Object entity, EntityMetadata metadata, Object rowKey) { try { Field idField = (Field) metadata.getIdAttribute().getJavaMember(); set(entity, idField, rowKey); } catch (IllegalArgumentException iarg) { throw new PropertyAccessException(iarg); } }
/** * Get identifier of an entity object by invoking getXXX() method. * * * @param entity * the entity * @param metadata * the metadata * * @return the id * * @throws PropertyAccessException * the property access exception */ public static Object getId(Object entity, EntityMetadata metadata) { // If an Entity has been wrapped in a Proxy, we can call the Proxy // classes' getId() method if (entity instanceof EnhanceEntity) { return ((EnhanceEntity) entity).getEntityId(); } // Otherwise, as Kundera currently supports only field access, access // the underlying Entity's id field return getObject(entity, (Field) metadata.getIdAttribute().getJavaMember()); }
/** * Fetches Row keys from a {@link List} of {@link KeySlice}. * * @param keySlices the key slices * @param metadata the metadata * @return the row keys */ public static List<Object> getRowKeys(List<KeySlice> keySlices, EntityMetadata metadata) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor((Field) metadata.getIdAttribute() .getJavaMember()); List<Object> rowKeys = new ArrayList<Object>(); for (KeySlice keySlice : keySlices) { byte[] key = keySlice.getKey(); Object rowKey = accessor.fromBytes(metadata.getIdAttribute().getJavaType(), key); rowKeys.add(rowKey); } return rowKeys; }
/** * Sets Primary Key (Row key) into entity field that was annotated with @Id. * * @param entity * the entity * @param metadata * the metadata * @param rowKey * the row key * @throws PropertyAccessException * the property access exception */ public static void setId(Object entity, EntityMetadata metadata, byte[] rowKey) { try { Field idField = (Field) metadata.getIdAttribute().getJavaMember(); set(entity, idField, rowKey); } catch (IllegalArgumentException iarg) { throw new PropertyAccessException(iarg); } }
Field field = (Field) attribute.getJavaMember();
.getIdAttribute().getJavaMember()); Object value = accessor.fromBytes(metadata.getIdAttribute().getJavaType(), rowKey.toByteArray());
if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) Field field = (Field) entityMetadata.getIdAttribute().getJavaMember(); EmbeddableType embeddableType = metaModel.embeddable(entityMetadata.getIdAttribute() .getBindableJavaType());
if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) Field field = (Field) entityMetadata.getIdAttribute().getJavaMember(); EmbeddableType embeddableType = metaModel.embeddable(entityMetadata.getIdAttribute() .getBindableJavaType());
/** * Populate id. * * @param entityMetadata * the entity metadata * @param schemaTable * the schema table * @param entity * the entity * @param row * the row */ private void populateId(EntityMetadata entityMetadata, Table schemaTable, Object entity, Row row) { FieldDef fieldMetadata; FieldValue value; String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName(); fieldMetadata = schemaTable.getField(idColumnName); value = row.get(idColumnName); NoSqlDBUtils.get(fieldMetadata, value, entity, (Field) entityMetadata.getIdAttribute().getJavaMember()); }
/** * Gets (if available) or creates a relationship for the given entity */ private Relationship getOrCreateRelationshipWithUniqueFactory(Object entity, EntityMetadata m, GraphDatabaseService graphDb) { Object id = PropertyAccessorHelper.getObject(entity, (Field) m.getIdAttribute().getJavaMember()); final String idFieldName = m.getIdAttribute().getName(); UniqueFactory<Relationship> factory = new UniqueFactory.UniqueRelationshipFactory(graphDb, m.getIndexName()) { @Override protected Relationship create(Map<String, Object> paramMap) { return null; } @Override protected void initialize(Relationship relationship, Map<String, Object> properties) { relationship.setProperty(idFieldName, properties.get(idFieldName)); } }; return factory.getOrCreate(idFieldName, id); }
Object rowKey = PropertyAccessorHelper.getObject(entity, (Field) attrib.getJavaMember()); if (!relations.isEmpty())
if (ObjectGraphUtils.onAutoGenerateId((Field) entityMetadata.getIdAttribute().getJavaMember(), id))
PropertyAccessorHelper.set(entity, (Field) entityMetadata.getIdAttribute().getJavaMember(), embeddedObject);
nodeId, entity, ((Field) entityMetadata.getIdAttribute().getJavaMember()).isAnnotationPresent(EmbeddedId.class) ? new ManagedState() : this.state, pd.getPersistenceCache(), entityId, pd);
fromNeo4JObject(rowKey, (Field) m.getIdAttribute().getJavaMember()));