Nhibernate compound primary key

Source: Internet
Author: User

Entity class:
Using system;
Using system. collections;

Namespace antu. Test {
# Region Flow

/// <Summary>
/// The Nhibernate ing Class flow of the database table "st_flow.
/// </Summary>
Public class Flow
{
# Region variable

Private flowkey _ flowkey;
Private string _ sname;
Private string _ ename;
Private bool _ isback;
Private float _ CX;
Private float _ Cy;
Private bool _ AC;

# Endregion

# Region Constructor

/// <Summary>
/// Initialize a new instance of the <see CREF = "flow"/> class.
/// </Summary>
Public flow (){}

/// <Summary>
/// Initialize a new instance of the <see CREF = "flow"/> class.
/// </Summary>
/// <Param name = "flowkey"> primary key. </Param>
/// <Param name = "sname">. </Param>
/// <Param name = "ename">. </Param>
/// <Param name = "isBack">. </Param>
/// <Param name = "cx">. </Param>
/// <Param name = "cy">. </Param>
/// <Param name = "ac">. </Param>
Public Flow (string sname, string ename, bool isBack, float cx, float cy, bool ac)
{
This. _ sname = sname;
This. _ ename = ename;
This. _ isBack = isBack;
This. _ cx = cx;
This. _ cy = cy;
This. _ ac = ac;
}

# Endregion

# Region attributes

/// <Summary>
/// Primary key.
/// </Summary>
Public virtual FlowKey MyFlowKey
{
Get {return _ flowKey ;}
Set {_ flowKey = value ;}
}

/// <Summary>
/// Start node.
/// </Summary>
Public virtual string Sname
{
Get {return _ sname ;}
Set
{
If (string. IsNullOrEmpty (value ))
Throw new ArgumentNullException ("Sname", "cannot be blank! ");
If (value! = Null & value. Length> 64)
Throw new ArgumentOutOfRangeException ("The Sname parameter value is invalid", value, value. ToString ());
_ Sname = value;
}
}

/// <Summary>
/// Terminate the node.
/// </Summary>
Public virtual string Ename
{
Get {return _ ename ;}
Set
{
If (string. IsNullOrEmpty (value ))
Throw new ArgumentNullException ("Ename", "cannot be blank! ");
If (value! = Null & value. Length> 64)
Throw new ArgumentOutOfRangeException ("the parameter value of Ename is invalid", value, value. ToString ());
_ Ename = value;
}
}

/// <Summary>
/// Whether it can be returned.
/// </Summary>
Public Virtual bool isback
{
Get {return _ isback ;}
Set {_ isback = value ;}
}

/// <Summary>
///.
/// </Summary>
Public Virtual float CX
{
Get {return _ CX ;}
Set {_ cx = value ;}
}

/// <Summary>
///.
/// </Summary>
Public virtual float Cy
{
Get {return _ cy ;}
Set {_ cy = value ;}
}

/// <Summary>
///.
/// </Summary>
Public virtual bool Ac
{
Get {return _ ac ;}
Set {_ ac = value ;}
}

# Endregion

}

/// <Summary>
/// Primary key class of the database table "ST_FLOW.
/// </Summary>
Public class FlowKey
{
Private string _ wid;
Private string _ fName;

/// <Summary>
/// Initialize a new instance of the <see cref = "StepKey"/> class.
/// </Summary>
Public FlowKey (){}

/// <Summary>
/// Initialize a new instance of the <see cref = "FlowKey"/> class.
/// </Summary>
/// <Param name = "wid"> process ID. </Param>
/// <Param name = "fName"> flow direction name. </Param>
Public FlowKey (string wid, string fName)
{
_ Wid = wid;
_ FName = fName;
}

/// <Summary>
/// Process ID.
/// </Summary>
Public string Wid
{
Set {_ wid = value ;}
Get {return _ wid ;}
}

/// <Summary>
/// Flow direction name.
/// </Summary>
Public string FName
{
Set {_ fName = value ;}
Get {return _ fName ;}
}

/// Two important steps
/// <Summary>
///
/// </Summary>
/// <Param name = "obj"> </param>
/// <Returns> </returns>
Public override bool Equals (object obj)
{
Return base. Equals (obj );
}

/// <Summary>
///
/// </Summary>
/// <Returns> </returns>
Public override int GetHashCode ()
{
Return base. gethashcode ();
}

}

# Endregion

Ing:
<? XML version = "1.0" encoding = "UTF-8"?>
<Hibernate-mapping xmlns = "urn: nhibernate-mapping-2.2">
<Class name = "antu. Data. Flow, antu. Data" table = "st_flow">
<Composite-ID class = "test. Data. flowkey, test. Data" name = "myflowkey">
<Key-property name = "wid" type = "string" column = "wid"/>
<Key-property name = "fname" type = "string" column = "fname"/>
</Composite-ID>
<Property name = "sname" type = "string">
<Column name = "sname" length = "64" SQL-type = "varchar2" not-null = "true"/>
</Property>
<Property name = "ename" type = "string">
<Column name = "ename" length = "64" SQL-type = "varchar2" not-null = "true"/>
</Property>
<Property name = "isback" type = "Boolean">
<Column name = "is_back" SQL-type = "Number" not-null = "true"/>
</Property>
<Property name = "CX" type = "single">
<Column name = "CX" SQL-type = "Number" not-null = "false"/>
</Property>
<Property name = "Cy" type = "Single">
<Column name = "CY" SQL-type = "NUMBER" not-null = "false"/>
</Property>
<Property name = "Ac" type = "Boolean">
<Column name = "AC" SQL-type = "NUMBER" not-null = "false"/>
</Property>
</Class>
</Hibernate-mapping>

// Call:
/// <Summary>
/// Update basic information data of land development and sorting.
/// </Summary>
/// <Param name = "iid"> case ID. </Param>
/// <Param name = "wid"> process ID. </Param>
/// <Param name = "fName"> flow direction name. </Param>
/// <! --
/// Created by: TEST
/// Creation Time: 2008-01-18
/// -->
Public static void UpdateBaseData (long iid, string wid, string fName)
{
// Update the status of each stage of the ut_kfzl_proj_neaten table
KfzlProjNeaten kfzlProjNeaten = KfzlProjNeatenHelper. Instance. Find (iid );
String [] arrstep = globalsetting. devsteppools. Split (',');

Flowkey key = new flowkey (WID, fname );
Flow flow = flowhelper. instance. Get (key );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.