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 库, ...
随机推荐
- 利用.dSYM跟.app文件准确定位Crash位置
本文转载至 http://blog.csdn.net/lvxiangan/article/details/28102629 利用.dSYM和.app文件准确定位Crash位置首先,确保 ...
- tp框架知识 之(链接数据库和操作数据内容)
框架有时会用到数据库的内容,在"ThinkPhp框架知识"的那篇随笔中提到过,现在这篇随笔详细的描述下. 一.链接数据库 (1)找到模块文件夹中的Conf文件夹,然后进行编写con ...
- 利用python进行数据分析之pandas入门
转自https://zhuanlan.zhihu.com/p/26100976 目录: 5.1 pandas 的数据结构介绍5.1.1 Series5.1.2 DataFrame5.1.3索引对象5. ...
- springcloud和kubernetes对比
由于这两个都不熟,所以在考虑学哪个. 先说结论:都要学,但是重点学k8s,k8s是一个更加完善的解决方案,springcloud被淘汰只是时间的问题. 从自己的经历和网上的文章两方面分析 个人经历: ...
- C#中的new和override(转)
在衍生类中的方法上使用new和override关键字有何意义,可以通过一系列问题来找到答案.先看一段代码: 1 class Program 2 { 3 static void Main(string[ ...
- 九度OJ 1164:旋转矩阵 (矩阵运算)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3188 解决:1245 题目描述: 任意输入两个9阶以下矩阵,要求判断第二个是否是第一个的旋转矩阵,如果是,输出旋转角度(0.90.180. ...
- 用 Apache POI 读取 XLSX 数据
最近因为项目的原因,需要从一些 Microsoft Office Excel 文件读取数据并加载到数据库. Google了一下方法,发现其实可以用的 Java 第三方库很多,最著名的是 Apache ...
- 我的Android进阶之旅------>Ubuntu下不能识别Android设备的解决方法
Bus 001 Device 006: ID 1b20:0c81 MStar Semiconductor, Inc. 今天不知道Ubuntu发了什么疯,昨天还用的好好的,今天就突然不能识别我 ...
- PAT 甲级 1104. Sum of Number Segments (20) 【数学】
题目链接 https://www.patest.cn/contests/pat-a-practise/1104 思路 最容易想到的一个思路就是 遍历一下所有组合 加一遍 但 时间复杂度 太大 会超时 ...
- jira与wiki官方文档记录
jira:https://confluence.atlassian.com/display/JIRA/Home wiki:https://confluence.atlassian.com/doc/co ...