It's my first time using NHibernate.
I had followed the tutorial over a nforge and had get myself started with my project. However I encountered an error which I do not know what is it all about.
Basically there are 2 classes for now. My database has a few more but I am working on this 2 first. Class 1 -- WaterBody Class 2 -- Exceedance
the relation between this 2 class is a one waterbody is to many exceedance.
this is my mapping file for the both of them ( I have no idea if I am doing it correctly)
Exceedance.hbm.xml
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="GEMSystem" namespace="GEMSystem.Models.Entities"> <class name="Exceedance" table="Exceedance"> <id name ="ExceedanceId" column="ExceedanceId" type="int"> <generator class="sequence"/> </id> <property name="WaterBodyId"> <column name="WaterBodyId" unique-key="WaterbodyParameter"/> </property> <property name ="Parameter"> <column name="Parameter" unique-key="WaterbodyParameter"/> </property>
<property name ="Min" /> <property name="Max" />
<many-to-one name="WaterBody" class="WaterBody" column="WaterBodyId" cascade="all"/> </class>
</hibernate-mapping>
---------------------------------------------------------------------------------------------------------- WaterBody.hbm.xml
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="GEMSystem" namespace="GEMSystem.Models.Entities"> <class name="WaterBody"> <id name="WaterBodyId" type="string" length="6"> <generator class="assigned" /> </id> <property name="Name" /> <property name="WaterBodyType" /> </class> </hibernate-mapping> ---------------------------------------------------------------------------------------------------------- My SQL Create statement for both tables
CREATE TABLE WaterBody ( WaterBodyId char(6) PRIMARY KEY , Name varchar2(50) , WaterBodyType char(2) );
CREATE TABLE Exceedance ( ExceedanceId number PRIMARY KEY , waterBodyId char(6) REFERENCES WaterBody(waterBodyId) , parameter varchar2(30) , min number , max number , UNIQUE ( waterBodyId , parameter ) );
---------------------------------------------------------------------------------------------------------- For now, I am able to retrieve any records from both the tables but when I try to add a exceedance record, it give me this error
I would like to have an auto-increment value of my ExceedanceId.
"Invalid index 5 for this OracleParameterCollection with Count=5."
Please help. Thank you
|