ORM映射关系:注解方式


  1. package org.crazyit.app.domain;
  2. import javax.persistence.*;
  3. import org.hibernate.annotations.Formula;
  4. @Entity(name="news_inf")
  5. public class News
  6. {
  7. // 消息类的标识属性
  8. @Id
  9. @GeneratedValue(strategy=GenerationType.IDENTITY)
  10. private Integer id;
  11. // 消息标题
  12. private String title;
  13. // 消息内容
  14. private String content;
  15. // 消息全部内容,由系统根据公式生成
  16. @Formula("(select concat(nt.title,nt.content)"
  17. + "from news_inf nt where nt.id= id)")
  18. private String fullContent;
  19. // id的setter和getter方法
  20. public void setId(Integer id)
  21. {
  22. this.id = id;
  23. }
  24. public Integer getId()
  25. {
  26. return this.id;
  27. }
  28. // title的setter和getter方法
  29. public void setTitle(String title)
  30. {
  31. this.title = title;
  32. }
  33. public String getTitle()
  34. {
  35. return this.title;
  36. }
  37. // content的setter和getter方法
  38. public void setContent(String content)
  39. {
  40. this.content = content;
  41. }
  42. public String getContent()
  43. {
  44. return this.content;
  45. }
  46. // fullContent的setter和getter方法
  47. public void setFullContent(String fullContent)
  48. {
  49. this.fullContent = fullContent;
  50. }
  51. public String getFullContent()
  52. {
  53. return this.fullContent;
  54. }
  55. }


主函数






最新文章

  1. SQLite学习笔记(八)&&sqlite实现架构
  2. 3.springMVC+spring+Mybatis整合Demo(单表的增删该查,这里主要是贴代码,不多解释了)
  3. 用nstimer实现倒计时
  4. DDD:四色原型中Role的 “六” 种实现方式
  5. oracle-asm,acfs
  6. JavaPersistenceWithHibernate第二版笔记-第六章-Mapping inheritance-001Hibernate映射继承的方法
  7. Unity3D学习笔记-------小地图制作
  8. .NET读取Excel
  9. ArrayBlockingQueue和LinkedBlockingQueue的区别
  10. Linux-vim学习入门
  11. Objective-c 多线程操作 自定义NSOperation 模拟下载
  12. Open-Falcon第五步安装Query(小米开源互联网企业级监控系统)
  13. HASH方法课下补分博客
  14. FFmpeg开发实战(六):使用 FFmpeg 将YUV数据编码为视频文件
  15. Android studio 下 JNI 开发实例
  16. 6、Qt Project之音视频播放
  17. H5C304
  18. 机器人学 —— 机器人感知(Location)
  19. C++的重载操作符(operator)介绍(转)
  20. JAVA编程思想学习笔记2-chap4-6-斗之气2段

热门文章

  1. 快速切题sgu127. Telephone directory
  2. POJ 2586 Y2K Accounting Bug 贪心 难度:2
  3. ADO.NET Entity Framework -Code Fisrt 开篇(一)
  4. [转载]python的常用代码模板
  5. 【LeetCode 234_链表】Palindrome Linked List
  6. Translate Exercises(4)
  7. Ubuntu16.04 和 hadoop2.7.3环境下 hive2.1.1安装部署
  8. OK335xS U-boot 编译问题&无Linux shell 问题
  9. ASCII编码和Unicode编码的区别
  10. hdu1255 覆盖的面积 线段树-扫描线