Hibernate Annotation (…
id
id
category_id
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
org.hibernate.dialect.MySQLDialect
jdbc:mysql://localhost:3307/users
com.mysql.jdbc.Driver
and
Product.java
javax.persistence.CascadeType;
数据库是users
可以省略
{
serialVersionUID = 3240281547213597385L;
HashSet(0);
description, Set products) {
主键生成方式:strategy = "increment"
strategy = "increment")
"generator")
nullable = false)
500)
500)
description) {
fetch = FetchType.LAZY, mappedBy = "category")
{
javax.persistence.GeneratedValue;
{
serialVersionUID = -1546206493725028472L;
name, String price,
{
strategy = "increment")
"generator")
nullable = false)
category) {
500)
10)
{
500)
descripton) {
{
HibernateTest();
AnnotationConfiguration();
sessionFactory=config.buildSessionFactory();
session=sessionFactory.getCurrentSession();
c=(Category)session.get(Category.class, 5);
p.setDescripton("计算机科学与技术,好啊,真是红啊");
AnnotationConfiguration();
sessionFactory=config.buildSessionFactory();
session=sessionFactory.getCurrentSession();
c=(Category)session.get(Category.class, 5);
System.out.println("id: "+c.getId()+"
name:"+c.getName());
p=c.getProducts();
product:p){
System.out.println("id:"+product.getId()+"
name:"+product.getName()+"
description:"+product.getDescripton());
session.getTransaction().commit();
logger (org.hibernate.cfg.annotations.Version).
system properly.
select
category0_.id as
id1_0_,
category0_.description as
descript2_1_0_,
category0_.name as
name1_0_
from
users.category
category0_
category0_.id=?
products0_.category_id as category5_1_,
products0_.id as id1_,
products0_.id as id0_0_,
products0_.category_id as category5_0_0_,
products0_.descripton as descripton0_0_,
products0_.name as name0_0_,
products0_.price as
price0_0_
users.product products0_
products0_.category_id=?
max(id)
product
insert
users.product
(category_id, descripton, name, price,
id)
(?, ?, ?, ?, ?)
category0_.id as id5_0_,
category0_.description as descript2_5_0_,
category0_.name as
name5_0_
users.category
category0_
category0_.id=?
products0_.category_id as category5_1_,
products0_.id as id1_,
products0_.id as id4_0_,
products0_.category_id as category5_4_0_,
products0_.descripton as descripton4_0_,
products0_.name as name4_0_,
products0_.price as
price4_0_
users.product products0_
products0_.category_id=?
description:计算机科学与技术,好啊,真是红啊
版权声明:本文为博主原创文章,未经博主允许不得转载。
Hibernate Annotation (…的更多相关文章
- Hibernate的Annotation注解
当项目变得比较大的时候,如何还使用hbm.xml文件来配置Hibernate实体就会变得比较复杂.这里Hibernate提供了Annotation注解方式,使得Hibernate的映射文件变得很方便管 ...
- Spring的annotation用在set方法上 hibernate的annotation用get方法上
1.Spring的annotation用在set方法上 2.hibernate的annotation用在get方法上
- Hibernate之Annotation(注解的方式,非映射)
在hibernate 3.0之后,可以建立一个符合JPA标准的Annotation,以hibernate3.3.2GA为例 Annotation 以 hibernate Annotation 3.3. ...
- Hibernate学习笔记2.2(Hibernate基础Annotation配置)
如果数据库表名与类名不一致 可以用使用 @Table(name="_teacher") 来指定表名,没有就会自己创建 也可以在配置文件上修改 为class添加table属性 如果什 ...
- hibernate spring annotation setup
First step setup for the pom.xml with hibernate dependency , hibernate dependency need to before the ...
- Hibernate常用Annotation标签说明
@ javax.persistence.Entity 实体类定义,该标签表示当前类是一个Hibernate的数据库实体,对应着数据库中的某个表 位置:用于类级别 参数:无 样例:@Entity 注意: ...
- Hibernate Annotation笔记
(1)简介:在过去几年里,Hibernate不断发展,几乎成为Java数据库持久性的事实标准.它非常强大.灵活,而且具备了优异的性能.在本文中,我们将了解如何使用Java 5 注释来简化Hiberna ...
- hibernate中增加annotation @后不提示信息【转】
此文转自:http://blog.knowsky.com/252047.htm 所需要用到的3个jar包分别是: hibernate-annotations.jar ejb3-persistence. ...
- Hibernate Annotation (Hibernate 注解)
简介: 传统上,Hibernate的配置依赖于外部 XML 文件:数据库映射被定义为一组 XML 映射文件,并且在启动时进行加载. 然而现在借助新的 Hibernate Annotation 库, ...
随机推荐
- 镜像回源主要用于无缝迁移数据到OSS,即服务已经在自己建立的源站或者在其他云产品上运行,需要迁移到OSS上,但是又不能停止服务,此时可利用镜像回写功能实现。
管理回源设置_管理文件_开发指南_对象存储 OSS-阿里云 https://help.aliyun.com/document_detail/31865.html 通过回源设置,对于获取数据的请求以多种 ...
- The template root requires exactly one element
The template root requires exactly one element
- python+NLTK 自然语言学习处理三:如何在nltk/matplotlib中的图片中显示中文
我们首先来加载我们自己的文本文件,并统计出排名前20的字符频率 if __name__=="__main__": corpus_root='/home/zhf/word' word ...
- yum 安装软件时出现 is this ok [y/d/n]
y下载安装 d只下载不安装 n不安装
- touchweb手机网站图片加载方法(canvas加载和延迟加载)
一.canvas图片加载 关于canvas加载,我的方法是,将文章中所有用到图片的地方,都用canvas代替,给canvas一个data-src,里面存放img的路径,通过canvas方法渲染图片.因 ...
- 创建blog APP
声明:此Django分类下的教程是追梦人物所有,地址http://www.jianshu.com/u/f0c09f959299,本人写在此只是为了巩固复习使用 什么是APP呢,Django里的APP其 ...
- VC++共享文件夹
BOOL NetShare(char * pShareName,char * pSharePath) { USES_CONVERSION; SHARE_INFO_502 si502; NET_API_ ...
- HTML5 拖放:在相册中对照片进行排序
1. [代码]index.html <div class="albums"> <div class="album" id=&qu ...
- RQNOJ 569 Milking Time:dp & 线段问题
题目链接:https://www.rqnoj.cn/problem/569 题意: 在一个数轴上可以摆M个线段,每个线段的起始终止端点给定(为整数),且每个线段有一个分值,问如何从中选取一些线段使得任 ...
- javascript(6)
javascript的冒泡排序 var arr=[5,0,-56,900,12]; //大的排序次数(arr.length-1) var flag=false; for(var i=0;i<=a ...