Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mobcoding
Study
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
develop
Breadcrumbs
Study
/
app
/
src
/
main
/
java
/
com
/
zero
/
study
/
db
/
entity
/
User.kt
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 1.5 KB
develop
Breadcrumbs
Study
/
app
/
src
/
main
/
java
/
com
/
zero
/
study
/
db
/
entity
/
User.kt
Copy path
Top
File metadata and controls
Code
Blame
39 lines (36 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package
com.zero.study.db.entity
import
androidx.room.ColumnInfo
import
androidx.room.Entity
import
androidx.room.Ignore
import
androidx.room.PrimaryKey
/*
*
* Date: 2022/05/11
* 数据实体
* TODO
* 1、@Entity:Room实体类注解 ---> 默认情况下,Room 将【类名称】用作数据库【表名称】
* 注:如果您希望【数据库表】具有不同的名称,请设置 @Entity 注解的 tableName 属性
* 2、PrimaryKey: 主键( autoGenerate = true 主键自增 ),作用:唯一标识相应数据库表中的每一行
* 3、@ColumnInfo:数据库表字段---> 默认情况下,使用【字段名称】作为数据库中的【列名称】
* 注:如果您希望【数据表里的列】具有不同的名称,请将 @ColumnInfo 注解添加到该字段并设置 name 属性
* 4、Ignore: 默认情况下,Room 会为实体中定义的每个字段创建一个列。 如果您不想保留该字段,则可以使用 @Ignore 为字段添加注解
*/
@Entity(tableName
=
"
t_user
"
)
data class
User
(
@PrimaryKey(autoGenerate
=
true
)
var
id
:
Int
=
0
,
@ColumnInfo(name
=
"
name
"
)
var
aliasName
:
String
=
"
"
,
var
age
:
Int
=
0
,
var
address
:
String
=
"
"
,
@Ignore
var
avatar
:
String
=
"
"
,
@ColumnInfo(name
=
"
money
"
)
var
money
:
Long
=
0
) {
constructor
(aliasName
:
String
, age
:
Int
, address
:
String
, avatar
:
String
)
:
this
() {
this
.aliasName
=
aliasName
this
.age
=
age
this
.address
=
address
this
.avatar
=
avatar
}
}
You can’t perform that action at this time.