public String getDbAttributeName() { return objAttribute.getDbAttributeName(); }
Expression buildIdQualifier(int index, Object[] data) { Map<String, Object> map; if(data[index] instanceof Map) { map = (Map<String, Object>)data[index]; } else { map = new HashMap<>(); int i = 0; for (ObjAttribute attribute : indexToEntity.get(index).getPrimaryKeys()) { map.put(attribute.getDbAttributeName(), data[index + i++]); } } return ExpressionFactory.matchAllDbExp(map, Expression.EQUAL_TO); }
private void appendSimpleProperties(Map dbDiff) { // populate changed columns if (currentPropertyDiff != null) { Iterator it = currentPropertyDiff.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); ObjAttribute attribute = (ObjAttribute) objEntity.getAttribute(entry .getKey() .toString()); // this takes care of the flattened attributes, as 'getDbAttributeName' // returns the last path component... Attribute dbAttribute = dbEntity.getAttribute(attribute .getDbAttributeName()); dbDiff.put(dbAttribute.getName(), entry.getValue()); } } }
<T> List<ColumnDescriptor> appendIdColumns(final List<ColumnDescriptor> columns, ObjEntity objEntity) { Set<ColumnTracker> skipSet = new HashSet<>(); DbEntity dbEntity = objEntity.getDbEntity(); for (ObjAttribute attribute : objEntity.getPrimaryKeys()) { // synthetic objattributes can't reliably lookup their DbAttribute, // so do it manually.. DbAttribute dbAttribute = dbEntity.getAttribute(attribute.getDbAttributeName()); appendColumn(columns, attribute, dbAttribute, skipSet, null); } return columns; }
public boolean visitAttribute(AttributeProperty property) { ObjAttribute oa = property.getAttribute(); if (visited.add(oa.getDbAttributePath())) { result.addObjectField(oa.getEntity().getName(), "fetch." + prefix + "." + oa.getName(), prefix + "." + oa.getDbAttributeName()); } return true; }
public EntityIdCoder(ObjEntity entity) { this.entityName = entity.getName(); this.converters = new TreeMap<String, Converter>(); for (ObjAttribute attribute : entity.getAttributes()) { if (attribute.isPrimaryKey()) { converters.put(attribute.getDbAttributeName(), create(attribute.getJavaClass())); } } for (DbAttribute attribute : entity.getDbEntity().getPrimaryKeys()) { if (!converters.containsKey(attribute.getName())) { String type = TypesMapping .getJavaBySqlType(attribute.getType()); try { converters.put(attribute.getName(), create(Util.getJavaClass(type))); } catch (ClassNotFoundException e) { throw new CayenneRuntimeException( "Can't instantiate class " + type, e); } } } if (converters.isEmpty()) { throw new IllegalArgumentException("Entity has no PK definied: " + entity.getName()); } this.idSize = (int) Math.ceil(converters.size() / 0.75d); }
public TargetPropertyWriter getOrCreateWriter(AttributeProperty property) { if (!entity.equals(property.getAttribute().getEntity())) { throw new LmRuntimeException("Property belongs to a different entity: " + property.getName()); } return getOrCreateWriter( property.getName(), ASTDbPath.DB_PREFIX + property.getAttribute().getDbAttributeName(), () -> new TargetAttributePropertyWriter(property) ); }
@Override public boolean visitAttribute(AttributeProperty property) { if (!entity.isIncluded(property.getName())) { return true; } Object value; if (entity.isConfidential(property.getName())) { value = Confidential.getInstance(); } else { String key = property.getAttribute().getDbAttributeName(); value = row.get(key); } if (value != null) { objectChangeSet.attributeChanged(property.getName(), value, null); } return true; }
@Override public boolean visitIdentifier(EJBQLExpression expression) { Map<String, String> fields = null; if (context.isAppendingResultColumns()) { fields = context.nextEntityResult().getFields(); } String idVar = expression.getText(); ClassDescriptor descriptor = context.getEntityDescriptor(idVar); ObjEntity oe = descriptor.getEntity(); for (ObjAttribute oa : oe.getPrimaryKeys()) { DbAttribute t = oe.getDbEntity().getAttribute(oa.getDbAttributeName()); appendColumn(idVar, oa, t, fields, oa.getType()); } return false; }
"ObjAttribute '%s' is mapped to a generated PK: %s", attribute.getName(), attribute.getDbAttributeName());
&& attribute.getDbAttribute().isGenerated()) { validator.registerWarning("ObjAttribute is mapped to a generated PK: " + attribute.getDbAttributeName(), path);