Role data access interface (iroledao. CS) Using System;
Using Guushuuse. salaryprj. Security. domainmodel;
Using System. collections;
Namespace Guushuuse. salaryprj. Security. Dao
{
/**/ /// <Summary>
///Role data access interface
/// </Summary>
Public Interface Iroledao
{
Void Createrole (role );
Void Deleterole (role );
Ilist getallroles ();
Role getrole ( Int Roleid );
Role getrole (Application application, String Rolename );
Ilist getroles (Application application );
Void Updaterole (role );
}
}
Role data category (roledao. CS) Using System;
Using System. Collections. Generic;
Using System. text;
Using Spring. Data. nhib.pdf. Support;
Using Spring. transaction. interceptor;
Using Guushuuse. salaryprj. Security. domainmodel;
Using System. collections;
Using Spring. Dao. Support;
Namespace Guushuuse. salaryprj. Security. Dao
{
/**/ /// <Summary>
///Role data category
/// </Summary>
Public Class Roledao: hibernatedaosupport, iroledao
{
Public Roledao ()
{
}
[Transaction (readonly = False )]
Public Void Createrole (role)
{
Hibernatetemplate. Save (role );
}
[Transaction (readonly = False )]
Public Void Updaterole (role)
{
Hibernatetemplate. Update (role );
}
[Transaction (readonly = False )]
Public Void Deleterole (role)
{
Hibernatetemplate. Delete (role );
}
Public Ilist getallroles ()
{
ReturnHibernatetemplate. loadall (Typeof(Role ));
}
Public Ilist getroles (Application)
{
String Hql = " From role R where R. Application =? " ;
Return Hibernatetemplate. Find (hql, New Object [] {Application} );
}
Public Role getrole ( Int Roleid)
{
Return(Role) hibernatetemplate. Get (Typeof(Role), roleid );
}
Public Role getrole (Application application, String Rolename)
{
String Hql = " From role where role. Application =? And role. Name =? " ;
Ilist roles = Hibernatetemplate. Find (hql, New Object [] {Application, rolename} );
If (Roles. Count > 0 )
{
Return(Role) dataaccessutils. requireduniqueresultset (roles );
}
Else
{
Return Null;
}
}
}
}