void init3rdPass() { super.init3rdPass(); }
private void init3rdPassRelations() { Set<String> toOneNames = new HashSet<>(); for (ToOne toOne : toOneRelations) { toOne.init3ndPass(); if (!toOneNames.add(toOne.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toOne); } } Set<String> toManyNames = new HashSet<>(); for (ToManyBase toMany : toManyRelations) { toMany.init3rdPass(); if (toMany instanceof ToMany) { Entity targetEntity = toMany.getTargetEntity(); for (Property targetProperty : ((ToMany) toMany).getTargetProperties()) { if (!targetEntity.propertiesColumns.contains(targetProperty)) { targetEntity.propertiesColumns.add(targetProperty); } } } if (!toManyNames.add(toMany.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toMany); } } }
void init2ndPass() { super.init2ndPass(); if (sourceProperties == null) { List<Property> pks = sourceEntity.getPropertiesPk(); if (pks.isEmpty()) { throw new RuntimeException("Source entity has no primary key, but we need it for " + this); } sourceProperties = new Property[pks.size()]; sourceProperties = pks.toArray(sourceProperties); } int count = sourceProperties.length; if (count != targetProperties.length) { throw new RuntimeException("Source properties do not match target properties: " + this); } for (int i = 0; i < count; i++) { Property sourceProperty = sourceProperties[i]; Property targetProperty = targetProperties[i]; PropertyType sourceType = sourceProperty.getPropertyType(); PropertyType targetType = targetProperty.getPropertyType(); if (sourceType == null || targetType == null) { throw new RuntimeException("Property type uninitialized"); } if (sourceType != targetType) { System.err.println("Warning to-one property type does not match target key type: " + this); } } }
Entity targetEntity = toMany.getTargetEntity(); checkAdditionalImportsEntityTargetEntity(targetEntity);
toMany.init2ndPass();
void init3rdPass() { super.init3rdPass(); List<Property> pks = sourceEntity.getPropertiesPk(); if (pks.isEmpty()) { throw new RuntimeException("Source entity has no primary key, but we need it for " + this); } List<Property> pks2 = targetEntity.getPropertiesPk(); if (pks2.isEmpty()) { throw new RuntimeException("Target entity has no primary key, but we need it for " + this); } }