When I was studying java in college, I learned how to use Hibernate for persistence layer operations. At that time, I just thought this framework was amazing and I could operate the database without writing SQL statements. At that time, I didn't know what it was, but I only knew how to use it and how to write XML configuration files. After all, at that time, there was a limited amount of code and there were not many programming ideas, and there was no way to do in-depth research. I have been doing this for some time. net development, its ORM Framework has the built-in Framework of Microsoft, of course, also evolved from Hibernate.. net platform. recently, I was curious about the internal conversion process. In the blog Park, I was lucky to have read a series of articles from the "Struggling" predecessors about writing ORM by myself, which was completed by C. I hope you can learn it together. The following is the reprinted content. This article mainly describes the final framework effect. In the future, we will use code to implement this framework step by step. After the final implementation, you only need to write a small amount of code to implement the CURD operation. DAL Layer Code: StudentDAL code public class StudentDAL {EntityManager entityManager = EntityManagerFactory. createEntityManager (); public StudentDAL () {} public StudentDAL (IDbTransaction transaction) {entityManager. transaction = transaction;} public List <StudentEntity> FindAll () {return entityManager. findAll <StudentEntity> ();} public int Save (StudentEntity entity) {return entityManager. save (entity );} Public int Update (StudentEntity entity) {return entityManager. update (entity);} public int Remove (StudentEntity entity) {return entityManager. remove (entity);} public int Remove (object id) {return entityManager. remove <StudentEntity> (id);} public List <StudentEntity> FindById (object id) {return entityManager. findById <StudentEntity> (id);} public List <StudentEntity> FindByProperty (string proper TyName, object value) {return entityManager. findByProperty <StudentEntity> (propertyName, value) ;}} ing relationship between entity classes and database tables configuration: StudentEntity code using System; using System. data; using System. collections. generic; using System. text; using System. orm. customAttributes; namespace Entity {[Serializable] [Table (name = "Student")] public class StudentEntity {private string stuid; private string stuno; private string name; Private int sex; private int age; private string address; private string telphone; [Id (Name = "stuid", Strategy = GenerationType. SEQUENCE)] public string Stuid {get {return stuid;} set {stuid = value;} [Column (Name = "studentno")] public string Stuno {get {return stuno;} set {stuno = value;} [Column (IsInsert = true)] public string Name {get {return name ;} set {name = value ;}} [Co Lumn (IsUpdate = true)] public int Sex {get {return sex;} set {sex = value ;}} public int Age {get {return age ;} set {age = value ;}} public string Address {get {return address;} set {address = value ;}} public string Telphone {get {return telphone ;} set {telphone = value ;}}} BLL Layer Code: StudentBLL code using System; using System. collections. generic; using System. text; using System. dat A; using DAL; using Entity; using System. orm. DBTransaction; namespace BLL {public class StudentBP {public List <StudentEntity> FindAll () {StudentDAL dal = new StudentDAL (); return dal. findAll ();} public void Save (StudentEntity entity) {IDbTransaction trans = null; try {trans = TransactionManager. createTransaction (); StudentDAL = new StudentDAL (trans); dal. save (entity); trans. commit ();} catch (Exception ex) {trans. rollback (); throw ex;} finally {trans. dispose () ;}} public void Remove (object id) {IDbTransaction trans = null; try {trans = TransactionManager. createTransaction (); StudentDAL = new StudentDAL (trans); dal. remove (id); trans. commit ();} catch (Exception ex) {trans. rollback (); throw ex;} finally {trans. dispose () ;}}} configure [Table (Name = "Student")] in the object class, corresponding to the Table Name in the database: Stud In the object class, configure [Id (Name = "studentid", Strategy = GenerationType. SEQUENCE)], indicating that the current attribute is the primary key ID in the Student table, Name = "studentid" indicates that the Stuid corresponds to the Student table column studentid, and Strategy indicates the primary key generation policy, which is auto-increasing. Configure [Column (Name = "studentno")] in the object class to indicate the Column Name in the studentno table corresponding to the current Stuno attribute: studentno (default attribute Name = Column Name) [Column (IsInsert = false)] is configured in the object class, indicating that the current Column value is not inserted into the database (default insertion). In the object class, [Column (IsUpdate = false)] is configured. indicates that the current column value is not updated to the database (default update) (Object Class ing configuration and some naming references JPA in JAVA)