Hello
How can I dynamically load "Person.hbm.xml"? Reason I need to do this is, M$SQL Server supports IDENTITY, Oracle needs to use SEQUENCE. So the "Id" column would be different when switching the application from M$SQL to Oracle at run-time/on-the-fly.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Util"
namespace="Util"
>
<class name="Person" table="Person">
<id name="Id" column="Id" type="Int64" unsaved-value="0">
<generator class="native" />
</id>
...
</class>
...
</hibernate>
When swtiched from M$SQL (Id=IDENTITY) to Oracle (SEQUENCE=PERSON_SEQ)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Util"
namespace="Util"
>
<class name="Person" table="Person">
<id name="Id" column="Id" type="Int64" unsaved-value="0">
<generator class="sequence">
<param name="sequence">PERSON_SEQ</param>
</generator>
</id>
...
</class>
...
</hibernate>
The problem is "Person.hbm.xml" is loaded as
"Embeded Resource"REF 1: generator=sequence
http://www.hibernate.org/hib_docs/nhibe ... pings.htmlREF 2: Startup loading code.
Code:
Configuration cfgPrimary = new Configuration(); cfgPrimary.Configure(".\\Resources\\nhibernate\\ThinkFundamentals.hibernate.cfg.xml");
cfgPrimary.AddClass(typeof(Util.Person));
ISessionFactory oNHFactoryPrimary = cfgPrimary.BuildSessionFactory();