Nhibernate 2+oracle 配置
时间:2011-03-31 来源:eolande
第一步:在oracle中创建表CAT
ID varchar2(32)
NAME varchar2(50)
SEX char(1)
WEIGHT float
创建sequence CAT_SEQUENCE
第二步:创建web应用程序QuickStart,
添加相关dll
Iesi.Collections.dll
LinFu.DynamicProxy.dll
log4net.dll
NHibernate.ByteCode.Castle.dll
NHibernate.ByteCode.LinFu.dll
NHibernate.dll
nunit.framework.dll
添加 xsd
nhibernate-configuration.xsd
nhibernate-mapping.xsd
第三步:创建实体类
public class CAT { public CAT(){} public virtual string ID { get; set; } public virtual string NAME { get; set; } public virtual char SEX { get; set; } public virtual float WEIGHT { get; set; } }
第四步:添加映射文件 Cat.hbm.xml,修改属性:【生成操作】【嵌入的资源】
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="QuickStart" namespace="QuickStart" > <class name="CAT" table="CAT"> <id name="ID" column="ID" type="string"> <!--<generator class="uuid.hex"/>--> <generator class="sequence"> <param name="sequence">CAT_SEQUENCE</param> </generator> </id> <property name="NAME"/> <property name="SEX"/> <property name="WEIGHT"/> </class> </hibernate-mapping>
第五步:添加配置文件 hibernate.cfg.xml
…
相关阅读 更多 +