forked from davidjava1991/java17CompleteCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
25 lines (22 loc) · 764 Bytes
/
Copy pathStudent.java
File metadata and controls
25 lines (22 loc) · 764 Bytes
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
package com.david.class136;
import java.lang.reflect.Field;
import java.util.Date;
import com.david.class136.DbColumn.Type;
public class Student {
@DbColumn(name ="studentId",length = 30)
int id;
@DbColumn(name ="studentName",length = 40,type =Type.VARCHAR)
String name;
@DbColumn(name ="DateOfBirth",length = 20,type =Type.DATE)
Date dob;
public static void main(String[] args) {
Field[] fields = Student.class.getDeclaredFields();
for(Field f : fields) {
DbColumn d = f.getDeclaredAnnotationsByType(DbColumn.class)[0];
System.out.println("=============");
System.out.println("Field name : "+d.name());
System.out.println("Field length : "+d.length());
System.out.println("Field Type : "+d.type());
}
}
}