【Hibernate学习笔记-5】@Formula注解的使用
2024-09-22 05:26:54
ORM映射关系:注解方式
package org.crazyit.app.domain;
import javax.persistence.*;
import org.hibernate.annotations.Formula;
@Entity(name="news_inf")
public class News
{
// 消息类的标识属性
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
// 消息标题
private String title;
// 消息内容
private String content;
// 消息全部内容,由系统根据公式生成
@Formula("(select concat(nt.title,nt.content)"
+ "from news_inf nt where nt.id= id)")
private String fullContent;
// id的setter和getter方法
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return this.id;
}
// title的setter和getter方法
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return this.title;
}
// content的setter和getter方法
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return this.content;
}
// fullContent的setter和getter方法
public void setFullContent(String fullContent)
{
this.fullContent = fullContent;
}
public String getFullContent()
{
return this.fullContent;
}
}
主函数
最新文章
- SQLite学习笔记(八)&;&;sqlite实现架构
- 3.springMVC+spring+Mybatis整合Demo(单表的增删该查,这里主要是贴代码,不多解释了)
- 用nstimer实现倒计时
- DDD:四色原型中Role的 “六” 种实现方式
- oracle-asm,acfs
- JavaPersistenceWithHibernate第二版笔记-第六章-Mapping inheritance-001Hibernate映射继承的方法
- Unity3D学习笔记-------小地图制作
- .NET读取Excel
- ArrayBlockingQueue和LinkedBlockingQueue的区别
- Linux-vim学习入门
- Objective-c 多线程操作 自定义NSOperation 模拟下载
- Open-Falcon第五步安装Query(小米开源互联网企业级监控系统)
- HASH方法课下补分博客
- FFmpeg开发实战(六):使用 FFmpeg 将YUV数据编码为视频文件
- Android studio 下 JNI 开发实例
- 6、Qt Project之音视频播放
- H5C304
- 机器人学 —— 机器人感知(Location)
- C++的重载操作符(operator)介绍(转)
- JAVA编程思想学习笔记2-chap4-6-斗之气2段
热门文章
- 快速切题sgu127. Telephone directory
- POJ 2586 Y2K Accounting Bug 贪心 难度:2
- ADO.NET Entity Framework -Code Fisrt 开篇(一)
- [转载]python的常用代码模板
- 【LeetCode 234_链表】Palindrome Linked List
- Translate Exercises(4)
- Ubuntu16.04 和 hadoop2.7.3环境下 hive2.1.1安装部署
- OK335xS U-boot 编译问题&;无Linux shell 问题
- ASCII编码和Unicode编码的区别
- hdu1255 覆盖的面积 线段树-扫描线