zoukankan      html  css  js  c++  java
  • 使用hibernate tools插件生成POJO

    很多时候我们已经设计好了数据库,需要使用hibernate来做数据持久化,因此需要根据数据库中的表结构生成相应的POJO.

    本例使用hibernatetools来自动创建pojo。

    测试环境:eclipse3.7(indigo)+hibernate4.1+hibernatetools3.3+oracle10g

    1.下载hibernatetools插件

    hibernatetools可从官网下载,但是需要注意下载和自己使用的eclipse版本对应的版本包,然后安装到eclipse中取,link安装方式参见:http://maimode.iteye.com/blog/1164524

    2.创建hibernate配置文件及console配置文件

    新建java项目,建立包test,test.hibernate,test.model。

    选中项目,右键-》new-》other-》hibernate-》hibernate configuration file:

    然后 next,配置console文件:

    3.创建reverse文件

    选中项目,右键-》new-》other-》hibernate-》hibernate reverse engineering file

    下一步,配置要生成POJO对应的表:

    4.反向工程创建pojo

    在hibernate code generation configuration菜单中配置

    执行run后便生成了相应的pojo文件:

    一般自动生成的mapping文件(XXX.hbm.xml)都需要修改后才能使用。

    http://maimode.iteye.com/blog/1630670

    我喜欢程序员,他们单纯、固执、容易体会到成就感;面对压力,能够挑灯夜战不眠不休;面对困难,能够迎难而上挑战自我。他 们也会感到困惑与傍徨,但每个程序员的心中都有一个比尔盖茨或是乔布斯的梦想“用智慧开创属于自己的事业”。我想说的是,其 实我是一个程序员
  • 相关阅读:
    Leetcode Binary Tree Preorder Traversal
    Leetcode Minimum Depth of Binary Tree
    Leetcode 148. Sort List
    Leetcode 61. Rotate List
    Leetcode 86. Partition List
    Leetcode 21. Merge Two Sorted Lists
    Leetcode 143. Reorder List
    J2EE项目应用开发过程中的易错点
    JNDI初认识
    奔腾的代码
  • 原文地址:https://www.cnblogs.com/kms1989/p/5476800.html
Copyright © 2011-2022 走看看