zoukankan      html  css  js  c++  java
  • 【Hibernate学习笔记-5】@Formula注解的使用



    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. }


    主函数










  • 相关阅读:
    蓝桥杯 十六进制转八进制
    蓝桥杯 字母图形
    2017.12.13T19_B2_5mianshiti
    2017.11.21T19_B2_6.2讲义
    2017.12.13T19_B2_6zuoye
    2017.12.1T19_B2_5zuoye
    2017.12.1T19_B2_4zuoye
    2017.12.1T19_B2_4——2
    2017.12.1T19_B2_4.3kehouzuoye
    2017.12.1T19_B2_4.2
  • 原文地址:https://www.cnblogs.com/ssslinppp/p/4546104.html
Copyright © 2011-2022 走看看