List<Property> properties = findPropertiesByColumns( columnOwner, columns, mappings );
//create an embeddable component
Property synthProp = null;
if ( properties != null ) {
//todo how about properties.size() == 1, this should be much simpler
Component embeddedComp = columnOwner instanceof PersistentClass ?
new Component( (PersistentClass) columnOwner ) :
new Component( (Join) columnOwner );
embeddedComp.setEmbedded( true );
embeddedComp.setNodeName( syntheticPropertyName );
embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() );
for (Property property : properties) {
Property clone = BinderHelper.shallowCopy( property );
clone.setInsertable( false );
clone.setUpdateable( false );
clone.setNaturalIdentifier( false );
embeddedComp.addProperty( clone );
}
synthProp = new Property();
synthProp.setName( syntheticPropertyName );
synthProp.setNodeName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );