Home > Java > javaTutorial > How does Java ORM work?

How does Java ORM work?

王林
Release: 2023-04-24 23:40:06
forward
1688 people have browsed it

1.ORM mapping relationship

In actual development, programmers use object-oriented technology to operate data, but when storing data, they use a relational database, so Caused a lot of inconvenience. ORM can build a bridge between the object model and the tables of the relational database. Programmers can use the API to directly operate JavaBean objects to implement operations such as data storage, query, change and deletion.

java orm的原理是什么

2. Principle of running process

Convert classes or objects into SQL statements, and then operate the database through a third-party connection. Users no longer need to write SQL statements, ORM does it all for you.

3. Example

public class M_People
 
    {
 
 
 
        string _Pl_ID;
 
        [DataFieldAttribute("Pl_ID", "Int")]
 
        public string Pl_ID
 
        {
 
            get { return _Pl_ID; }
 
            set { _Pl_ID = value; }
 
        }
 
 
 
        int _PL_Age;
 
        [DataFieldAttribute("PL_Age", "Int")]
 
        public int PL_Age
 
        {
 
            get { return _PL_Age; }
 
            set { _PL_Age = value; }
 
        }
 
 
 
        string _Pl_Sex;
 
        [DataFieldAttribute("Pl_Sex", "nvarchar")]
 
        public string Pl_Sex
 
        {
 
            get { return _Pl_Sex; }
 
            set { _Pl_Sex = value; }
 
        }
 
 
 
        string _Pl_LoginName;
 
        [DataFieldAttribute("Pl_LoginName", "nvarchar")]
 
        public string Pl_LoginName
 
        {
 
            get { return _Pl_LoginName; }
 
            set { _Pl_LoginName = value; }
 
        }
 
 
 
        string _Pl_TrueName;
 
        [DataFieldAttribute("Pl_TrueName", "nvarchar")]
 
        public string Pl_TrueName
 
        {
 
            get { return _Pl_TrueName; }
 
            set { _Pl_TrueName = value; }
 
        }
 
 
 
        string _PL_Pwd;
 
        [DataFieldAttribute("PL_Pwd", "nvarchar")]
 
        public string PL_Pwd
 
        {
 
            get { return _PL_Pwd; }
 
            set { _PL_Pwd = value; }
 
        }
 
 
 
}
Copy after login

By customizing Attribute, we define a one-to-one correspondence between class attributes and database fields.

The above is the detailed content of How does Java ORM work?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template