ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:18.49KB ,
资源ID:5228492      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5228492.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(使用XDoclet2+Ant实现Hibernate3的pojoxmldb代码相互转换.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

使用XDoclet2+Ant实现Hibernate3的pojoxmldb代码相互转换.docx

1、使用XDoclet2+Ant实现Hibernate3的pojoxmldb代码相互转换使用XDoclet2+Ant实现Hibernate3的pojo-xml-db代码相互转换XDoclet是一款开源的代码自动生成引擎,支持很多框架的代码自动生成。而XDoclet2作为Maven2的插件,支持Hibernate3的pojo-xml的代码自动生成。配合ant与Hibernate Tool API,可以实现pojoxmldb schema的相互转化。具体关系为: 生成处理 实用工具 pojo-xml XDoclet2 xml-pojo Hibernate Tool API pojo+xml - db

2、schema Hibernate Tool API db schema - pojo+xml 可用myeclipse,本文不涉及下面通过ANT脚本例子,来展示如何完成以上的转换。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 28 29 30 31 32 33 34 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 71 72 73 74 75 76 77 脚本很详细,看注释即可。在使用xdo

3、clet2hbm前,需要在pojo上设定javadoc注释,以告诉xdoclet如何进行解析。one2one & one2many的例子:Child.java 1 package po; 2 3 /* 4 * hibernate.class table=child 5 */ 6 SuppressWarnings(serial) 7 public class Child implements java.io.Serializable 8 9 /xdoclet注释有写在getter上与写在field上2种方法。10 /写在field上会自动生成access=field,所以写在getter上更常用

4、一些。11 12 private String id;13 private String name;14 private Father father;15 16 /*17 * hibernate.id generator-class=uuid.hex column=id length=3218 */19 public String getId() 20 return this.id;21 22 23 public void setId(String id) 24 this.id = id;25 26 27 /基本支持所有的hibernate 属性,所以想要啥设置就大胆的写吧28 /*29 *

5、hibernate.property column=name length=32 not-null=true type=java.lang.String lazy=true30 */31 public String getName() 32 return this.name;33 34 35 public void setName(String name) 36 this.name = name;37 38 39 /*40 * hibernate.many-to-one column=father_id not-null=true41 */42 public Father getFather(

6、) 43 return this.father;44 45 46 public void setFather(Father father) 47 this.father = father;48 49 50 Father.java 1 package po; 2 3 import java.util.HashSet; 4 import java.util.Set; 5 6 /* 7 * hibernate.class table=father 8 */ 9 SuppressWarnings(serial)10 public class Father implements java.io.Seri

7、alizable 11 12 private String id;13 14 private String name;15 16 private Integer age;17 18 private Set children = new HashSet(0);19 20 /*21 * hibernate.id generator-class=uuid.hex column=id length=3222 */23 public String getId() 24 return this.id;25 26 27 public void setId(String id) 28 this.id = id

8、;29 30 31 /*32 * hibernate.property column=name length=32 not-null=true type=java.lang.String33 */34 public String getName() 35 return this.name;36 37 38 public void setName(String name) 39 this.name = name;40 41 42 /*43 * hibernate.property column=age length=32 type=java.lang.Integer44 */45 public

9、Integer getAge() 46 return age;47 48 49 public void setAge(Integer age) 50 this.age = age;51 52 53 /*54 * hibernate.set table=child55 * hibernate.key column=father_id56 * hibernate.one-to-many class=po.Child57 */58 public Set getChildren() 59 return children;60 61 62 public void setChildren(Set chil

10、dren) 63 this.children = children;64 65 many2many的例子:Student.java 1 package po; 2 3 import java.util.HashSet; 4 import java.util.Set; 5 6 /* 7 * hibernate.class table=student 8 */ 9 SuppressWarnings(serial)10 public class Student implements java.io.Serializable 11 12 private String id;13 private Str

11、ing name;14 private Set teachers = new HashSet(0);15 16 /*17 * hibernate.id generator-class=uuid.hex column=id length=3218 */19 public String getId() 20 return this.id;21 22 23 public void setId(String id) 24 this.id = id;25 26 27 /*28 * hibernate.property column=name length=32 not-null=true type=ja

12、va.lang.String29 */30 public String getName() 31 return this.name;32 33 34 public void setName(String name) 35 this.name = name;36 37 38 /*39 * hibernate.set table=student_teacher_relation40 * hibernate.key column=student_id41 * hibernate.many-to-many class=po.Teacher column=teacher_id42 */43 public

13、 Set getTeachers() 44 return teachers;45 46 47 public void setTeachers(Set teachers) 48 this.teachers = teachers;49 50 Teacher.java 1 package po; 2 3 import java.util.HashSet; 4 import java.util.Set; 5 6 /* 7 * hibernate.class table=teacher 8 */ 9 SuppressWarnings(serial)10 public class Teacher impl

14、ements java.io.Serializable 11 12 private String id;13 private String name;14 private Set students = new HashSet(0);15 16 /*17 * hibernate.id generator-class=uuid.hex column=id length=3218 */19 public String getId() 20 return this.id;21 22 23 public void setId(String id) 24 this.id = id;25 26 27 /*2

15、8 * hibernate.property column=name length=32 not-null=true type=java.lang.String29 */30 public String getName() 31 return this.name;32 33 34 public void setName(String name) 35 this.name = name;36 37 38 /*39 * hibernate.set table=student_teacher_relation40 * hibernate.key column=teacher_id41 * hiber

16、nate.many-to-many class=po.Student column=student_id42 */43 public Set getStudents() 44 return students;45 46 47 public void setStudents(Set students) 48 this.students = students;49 50 51 总结:1.本文没有涉及hibernate annnotation模式,需要者请自行查阅相关资料。2.XDoclet2没有XDoclet1代好找,推荐一个网址 Jar Search Engine3.本文未能涉及在开发中,程序运转时遇到DB schema结构变化而进行的动态自动转换技术。如有高人知晓,请不吝赐教。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1