/* * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.xutils.sample.db; import org.xutils.DbManager; import org.xutils.db.annotation.Column; import org.xutils.db.annotation.Table; import org.xutils.ex.DbException; /** * Author: wyouflf * Date: 13-7-29 * Time: 下午5:04 */ @Table(name = "child") public class Child { @Column(name = "id", isId = true) private int id; @Column(name = "name") private String name; @Column(name = "email") private String email; @Column(name = "parentId" /*, property = "UNIQUE"//如果是一对一加上唯一约束*/) private long parentId; // 外键表id // 这个属性被忽略,不存入数据库 private String willIgnore; @Column(name = "text") private String text; public Parent getParent(DbManager db) throws DbException { return db.findById(Parent.class, parentId); } public long getParentId() { return parentId; } public void setParentId(long parentId) { this.parentId = parentId; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getWillIgnore() { return willIgnore; } public void setWillIgnore(String willIgnore) { this.willIgnore = willIgnore; } public String getText() { return text; } public void setText(String text) { this.text = text; } @Override public String toString() { return "Child{" + "id=" + id + ", name='" + name + '\'' + ", email='" + email + '\'' + ", parentId=" + parentId + ", willIgnore='" + willIgnore + '\'' + ", text='" + text + '\'' + '}'; } }