Question: So NSXMLParser has problems parsing strings using the Windows-1252 encoder. Now I did find a solution on this page to convert it to NSUTF8StringEncoding. But now it bumps into characters it can't parse.

So I figured out that it will work if I would escape special characters and then transfer it back after parsing it. For example:

```
string = [string stringByReplacingOccurrencesOfString:@":" withString:@"__58__"];

```

Since it is allowed to use the \_ character without getting a parser error and in NSXMLParser I can transfer the value back to it's proper character.

So is there a way I can loop through all ASCII character so I can replace all special characters (Except <, > and \_ of course)?

Answer: 
Set inverse to false for <map> element.
Try this:

```
<map name="Urls" lazy="true" cascade="all-delete-orphans">

```

* You don't need `table`, because the table is defined in the class `UserUrl` mapping
* You should not make it inverse, if it is not
* You should cascade it all-delete-orphan to tell NH to remove items that are removed from the collection.

---

Not related to your questions, why do you have this in the url?

```
<property name="user_id" column="user_id" type="Int32" not-null="true"/>

```

You are mapping the foreign key there! I would never ever dare to do this.

---

Actually, I'm not sure if you should not actually map it like this:

```
<map name="Urls" table="UserUrl" lazy="true" cascade="all-delete-orphans">
   <key column="user_id"/>
   <index column="url_type_id" type="Int32"/>
   <composite-element>
     <property name="UrlType" column="url_type_id" type="Int32" not-null="true"/>
     <property name="Url" column="url" type="String" not-null="true"/>
   </composite-element>
 </map>

```

If the Url is not an independent entity, having an own Id, then you could map it as composite-element. The url is treated as a value type. There is no class `UserUrl` mapping anymore.

**Edit:** 

* See the [NH Reference Chapter 7](http://knol.google.com/k/fabio-maulo/nhibernate-chapter-7/1nr4enxv3dpeq/10), it explains the components.
* If you get not-null problems on references, just remove the not-null
constraint on the foreign key. NH needs to insert some columns to get
primary keys if you use `generator class="identity"`, so it stores
a null temporary.