Hi!
An application I'm working on has different items that, as an upcoming
feature, should be assignable to sets:
Items
Id
ProducerId
ItemSetId (nullable)
Name
Weight
ItemSets
Id
ProducerId
Views
Id
ProducerId
ItemSetId (nullable)
Producer
Id
Name
In the current production database, the ItemSetId column and the
ItemSets table don't exist yet.
To provide an upgrade path, I thought it would be a good idea to have an
implicit NULL ItemSet in which all items are contained where the
ItemSetId column is NULL. That way, any old views where the ItemSetId is
NULL would automatically get any items not assigned to a set.
However, I'm not sure how to realize this in NHibernate. For example,
return Session.CreateCriteria<ItemSet>()
.Add(Restrictions.Eq("ProducerId", producerId))
.List<ItemSet>();
will return all ItemSets from the ItemSets table with the specified
ProducerId, but of course there won't be a NULL ItemSet because none is
contained in the table. If I add it post-query to the returned
IList<ItemSet>, NHibernate would assume that I intend to add it to my
database.
Any suggestions on how to best approach this? Or is this idea for an
upgrade path flawed from the get go?
-Markus-
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com.
To unsubscribe from this group, send email to
nhusers+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.