You can solve it with custom type:
1. Write a custom type, which will read Category Id from recordset and load necessary Category object from Session 2 (created by Factory 2). For saving it will save the Id of the Category object to the table. Essentially - the same in reverse order.
2. Map your property as a "property" (not "many-to-one", etc.) and specify your custom type.
It shoud be enough.
In general, it's almost your solution "just persist the Category Primary Key", but you will not have to load objects manually.
Please note, that this mapping is not a mapping between entities, so you will have to take care of cascading issues by yourself.
_________________ Best,
Andrew Mayorov // BYTE-force
|