03hibernate Annotation版本的hibernate

来源:互联网 发布:淘宝图片尺寸和像素 编辑:程序博客网 时间:2024/05/24 07:19
</pre><pre name="code" class="javascript">1.创建teacher表2.创建teacher类3.引入Jar包hibernate-annotation.jar<span style="white-space:pre"></span>ejb3-persistence.jar//符合了jpa标准的annotation的实现hibernate-common-annotation.jar//进行反射时需要使用的包4.Teacher类前加上@Entity //javax.persistence.Entity说明该类是个实体,默认表名和类名相同getId()上面加@Id5.在hibernate.cfg.xml中说明给Teacher类加上了注解<mapping class="包名.类名"/>6.测试需要修改:Configuration cfg = new AnnotationConfiguration();FAQ:@不给提示content assist-activation-加入@


0 0