Dan
未读,2009年11月24日 10:11:202009/11/24登录即可回复作者
登录即可转发
您无权在此群组中删除帖子
要么此群组的电子邮件地址为匿名状态,要么您得查看成员电子邮件地址权限才能查看原始帖子
收件人 nhusers
Within our system we have the concept of an employee. It contains your
basic employee data such as name, address, etc. We are in the process
of building a new application that needs this core employee data but
also needs to track information about a driver. Because a driver has
the same characteristics as an employee we are building this using the
joined-subclass functionality in NHibernate. The employee is the
"base" class, and the driver inherits from it, plus it has a few extra
properties.
Tables:
Employee
Name, Address, etc
Driver
Drivers license number, etc....
I'm finding that if a record has been persisted through the employee,
there isn't a way to load that employee a driver. Which makes sense
because a driver record with the employee's primary key was not
created. The reason that this is needed is due to the fact that we
have a set of "core" tables that are shared across many of our
applications. In this case that table is Employee. Depending upon what
application you're working with the context changes. Some applications
you're managing employees, and in another you're managing drivers.
So here is my question. Without writing some hack to insert a driver
record in the database; Is there a way that I can load an employee in
the context of a driver and have NHibernate understand that once it is
persisted the employee record is an update, and the driver record
would be an insert if it is the first time opening it in the driver
context? Else, it is just an update to both tables.
Thanks,
Dan