hibernate的映射有2种方式
xml和 annotaion
xml的好处是:它是配置!是脱离代码之外的东西,可以允许你在你的项目部署之后,再去做细微修改(如果你的项目做得有弹性的话)
xml的缺点:繁琐!写了一大堆,发现节点的字数比真实数据的字数多太多了...浪费!
annotation的好处:维护的页面少!不用写项目的时候在N的文档直接,切来切去的!而且非常简练,比xml少非常多!
annotation的坏处:和程序纠缠在了一起...
推荐用法:
在项目开发阶段用annotation做配置,这样可以大大提高项目的效率
等到项目开发,测试完成之后,再重新写回xml然后再去部署
用xml比较标准,而且清楚
xml
<p>hibernate.dialect net.sf.hibernate.dialect.mysqldialect<br>hibernate.connection.driver_class org.gjt.mm.mysql.driver<br>hibernate.connection.driver_class com.mysql.jdbc.driver<br>hibernate.connection.url jdbc:mysql://localhost:3306/test<br>hibernate.connection.username root<br>hibernate.connection.password </p> <p> </p> <p><?xml version='1.0' encoding='utf-8'?><br><!doctype hibernate-configuration<br> public "-//hibernate/hibernate configuration dtd//en"<br>" <a
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....