I have a strange situation I need to persist:
public class Person
{
public string[] Nicknames { get; set; }
}
What mapping and table structur
You can use some logic of yours to achieve the same thing right.. probably adding your own delimiter between the nicknames and then split it by this delimiter once you read it into memory.
public class Person
{
public string Nicknames { private get; set; }
public string[] ArrayOfNicknames
{
get
{
return Nicknames.Split(<your_delimiter>);
}
}
}
You can map arrays directly, but you'll need a few additional columns:
<!-- can live w/o orderby -->
<array name="Nicknames" table="Nicknames" order-by="indexColumn ASC">
<key column="keyColumn"/>
<index column="indexColumn"/> <!-- position in array -->
<element column="nickname" type="String"/>
</array>
If you don't have the other columns you need, I would probably persist it as a normal bag or list and expose it as an array from that in the entity.