我们可以让Domain Object更rich:)
1package com.martin.pdo;
2
3import java.io.Serializable;
4import java.util.List;
5
6/**
7 * @author martin.xus
8 * @hibernate.class table="t_user"
9 * @spring.bean name="user"
10 * @spring.property name="manager" ref="userManager"
11 */
12public class User implements Serializable {
13
14 /**
15 * @hibernate.id generator-class="uuid.hex"
16 * length="32"
17 * column="user_id"
18 */
19 private String id;
20
21 /**
22 * @hibernate.property column="user_name"
23 * length="80"
24 */
25 private String name;
26
27 /**
28 * @hibernate.property
29 */
30 private char sex;
31
32 /**
33 * @hibernate.property
34 */
35 private int age;
36
37 //省略了getter & setter
38 private UserManager manager = null;
39
40 /**
41 * @return Returns the manager.
42 */
43 public UserManager getManager() {
44 return manager;
45 }
46
47 /**
48 * @param manager The manager to set.
49 */
50 public void setManager(UserManager manager) {
51 this.manager = manager;
52 }
53
54 /**
55 * @param user
56 */
57 public void add(User user) {
58 this.getManager().add(user);
59 }
60
61 public List loadByName(String name) {
62 return this.getManager().loadByName(name);
63 }
64
65 public void remove(User user) {
66 this.getManager().remove(user);
67 }
68}
69
2
3import java.io.Serializable;
4import java.util.List;
5
6/**
7 * @author martin.xus
8 * @hibernate.class table="t_user"
9 * @spring.bean name="user"
10 * @spring.property name="manager" ref="userManager"
11 */
12public class User implements Serializable {
13
14 /**
15 * @hibernate.id generator-class="uuid.hex"
16 * length="32"
17 * column="user_id"
18 */
19 private String id;
20
21 /**
22 * @hibernate.property column="user_name"
23 * length="80"
24 */
25 private String name;
26
27 /**
28 * @hibernate.property
29 */
30 private char sex;
31
32 /**
33 * @hibernate.property
34 */
35 private int age;
36
37 //省略了getter & setter
38 private UserManager manager = null;
39
40 /**
41 * @return Returns the manager.
42 */
43 public UserManager getManager() {
44 return manager;
45 }
46
47 /**
48 * @param manager The manager to set.
49 */
50 public void setManager(UserManager manager) {
51 this.manager = manager;
52 }
53
54 /**
55 * @param user
56 */
57 public void add(User user) {
58 this.getManager().add(user);
59 }
60
61 public List loadByName(String name) {
62 return this.getManager().loadByName(name);
63 }
64
65 public void remove(User user) {
66 this.getManager().remove(user);
67 }
68}
69
测试代码,我们可以这样来写
1ApplicationContext context = JUnitTestHelper.getContext();
2 User user = (User) context.getBean("user");
3
4 User _u1 = new User();
5 _u1.setName("martin xus");
6 _u1.setSex('F');
7 _u1.setAge(100);
8
9 user.add(_u1);
10
11 Assert.assertEquals(((User) user.loadByName("martin xus").get(0)).getId(), _u1.getId());
12
2 User user = (User) context.getBean("user");
3
4 User _u1 = new User();
5 _u1.setName("martin xus");
6 _u1.setSex('F');
7 _u1.setAge(100);
8
9 user.add(_u1);
10
11 Assert.assertEquals(((User) user.loadByName("martin xus").get(0)).getId(), _u1.getId());
12
相关推荐
Domain Object领域模型学习、设计、分析资料,错过别后悔。
Unsupervised Domain Adaption of Object Detectors A Survey.zip
Unsupervised Domain Adaption of Object Detectors A Survey.pdf
A Survey on Deep Domain Adaptation and Tiny Object Detection Challenges, Techniques and Datasets.pdf
A Survey on Deep Domain Adaptation and Tiny Object Detection Challenges, Techniques and Datasets.zip
目标检测,机器学习
Cross-Domain Weakly-Supervised Object Detectio.pdf
深入理解ApplicationDomain和SecurityDomain
Connecting model and implementation more deeply * Sharpening key distinctions in a model * Managing the lifecycle of a domain object * Writing domain code that is safe to combine in elaborate ways * ...
Wavelet Transform Domain Filters
that go beyond image classification, such as face recognition, semantic segmentation and object detection. Fourth, some potential deficiencies of current methods and several future directions are ...
Domain adaptation is one of the most challenging tasks of modern data analytics. If the adaptation is done correctly, models built on a specific data representation become more robust when confronted ...
失血模型简单来说,就是domain object只有属性的getter/setter方法的纯数据类,所有的业务逻辑完全由business object来完成(又称TransactionScript),这种模型下的domain object被Martin Fowler称之为“贫血的domain...
crossdomain.xml用于unity3d生成的webplayer不能读取数据库的问题,用于unity3d生成的webplayer不能读取数据库的问题
详细介绍ApplicationDomain和SecurityDomain的原理,想对这方面的知识做深入研究的可以看下
By the end of the book, you will learn to use other design patterns such as DSLs to extend DDD with object-oriented design base, and then get an insight into how to select the right scenarios to ...
我个人认为DDD最大的好处是将业务语义显现化,把原先晦涩难懂的业务算法逻辑,通过领域对象(Domain Object),统一语言(Ubiquitous Language)将领域概念清晰的显性化表达出来。相信我,这种表达带来的代码可读性...
as object recognition, face recognition, activity analysis, concept clas- sification, and person detection. We then conclude by analyzing the challenges posed by the realm of “big visual data”, in ...
明小子Domain4.3永久破解版