Skip to content

Commit ed08add

Browse files
author
huxinwu
committed
修改
1 parent 498fb76 commit ed08add

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package gentest;
17+
18+
import de.greenrobot.daogenerator.DaoGenerator;
19+
import de.greenrobot.daogenerator.Entity;
20+
import de.greenrobot.daogenerator.Schema;
21+
22+
/**
23+
* Generates entities and DAOs for the example project DaoExample.
24+
*
25+
* Run it as a Java application (not Android).
26+
*
27+
* @author Markus
28+
*/
29+
public class quLoveDaoGenerator {
30+
31+
public static void main(String[] args) throws Exception {
32+
// com.shengdao.demo.utils.db是生成的类package的值
33+
Schema schema = new Schema(3, "com.jingdl.qulove.utils.db");
34+
35+
// 添加Note对象的Schema,会生成针对Note的数据库相关代码
36+
addFriend(schema);
37+
38+
addNotice(schema);
39+
40+
// C://Users/huxinwu/Desktop/demo C://Users/Administrator/Desktop/db
41+
// 该地址是生成的代码存放地址,相对地址不好写就写绝对地址,生成后直接拷贝到对应的地址(com.shengdao.demo.utils.db)下面
42+
new DaoGenerator().generateAll(schema, "C://Users/Administrator/Desktop/db");
43+
}
44+
45+
/**
46+
* @param schema
47+
*/
48+
private static void addFriend(Schema schema) {
49+
Entity note = schema.addEntity("Friend");
50+
note.addStringProperty("userId").notNull().primaryKey();
51+
note.addStringProperty("uesrName");
52+
note.addStringProperty("portraitUri");
53+
}
54+
55+
/**
56+
* @param schema
57+
*/
58+
private static void addNotice(Schema schema) {
59+
Entity note = schema.addEntity("Notice");
60+
note.addIdProperty().autoincrement().primaryKey();
61+
note.addStringProperty("pushContent");
62+
note.addStringProperty("targetid");
63+
note.addStringProperty("time");
64+
}
65+
66+
}

0 commit comments

Comments
 (0)