ASP. NET & Spring. Net & nhib.pdf Best Practices (12) -- Chapter 1 permission subsystem (5)

Source: Internet
Author: User
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;
}
}
}
}

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.