private void removeHasOneToBothPrimaryAndForeignKey() {
		String[] primaryKeys = model.getPrimaryAttributes();
		String[] hasOne = model.getHasOne();
		String[] hasOneLocal = model.getHasOneLocalColumn();
		String[] hasOneReferenced = model.getHasOneReferencedColumn();
		for(String pk : primaryKeys){
			int pkIndex = CStringUtils.indexOf(hasOneLocal, pk);
			if(pkIndex >= 0){
				System.out.println("\n"+pk+" is a primary key of ["+model.getTableName()+"] ("+hasOneLocal[pkIndex]+")"
						+ "and foreign key to ["+hasOne[pkIndex]+"]("+hasOneReferenced[pkIndex]+")");
				System.out.println("removing ["+hasOne[pkIndex]+"] from ["+model.getTableName()+"]");
				model = removeFromHasOne(model, hasOne[pkIndex]);
			}
		}
	}
private void removeHasOneToBothPrimaryAndForeignKey ( ) { String [ ] primaryKeys = model . getPrimaryAttributes ( ) ; String [ ] hasOne = model . getHasOne ( ) ; String [ ] hasOneLocal = model . getHasOneLocalColumn ( ) ; String [ ] hasOneReferenced = model . getHasOneReferencedColumn ( ) ; for ( String pk : primaryKeys ) { int pkIndex = CStringUtils . indexOf ( hasOneLocal , pk ) ; if ( pkIndex >= 0 ) { System . out . println ( "\n" + pk + " is a primary key of [" + model . getTableName ( ) + "] (" + hasOneLocal [ pkIndex ] + ")" + "and foreign key to [" + hasOne [ pkIndex ] + "](" + hasOneReferenced [ pkIndex ] + ")" ) ; System . out . println ( "removing [" + hasOne [ pkIndex ] + "] from [" + model . getTableName ( ) + "]" ) ; model = removeFromHasOne ( model , hasOne [ pkIndex ] ) ; } } }
user_info.user_id is the primary key while it is refering to users.user_id
user_info.User will create a cyclic recursive mapping to users and user_info and back.
Remove that hasOne which is both primary and foreign to prevent that.