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 库, ...
随机推荐
- python 基础 1.5 python数据类型(三)--元组常用方法示例
#/usr/bin/python#coding=utf-8#@Time :2017/10/13 15:02#@Auther :liuzhenchuan#@File :元组.py #tuple() 字符 ...
- toggle不支持事件代理的解决办法或者 jquery live绑定toggle
$(".xxx").live("click", function () { $(this).toggle(function () {},functio ...
- linux c编程:gdb的使用
首先用一个简单的打印字符的程序来做下示例 #include<stdio.h>#include<string.h>void main(){ int i=0; char ...
- 关于wx.redirectTo、wx.navigateTo失效问题
问题:在app.json页面中若配置了tabBar,并且要跳转的目标页面也在tabBar中时,那么常用的几种页面跳转方式便失效了.即不能跳转到tabBar中定义的页面. 解决办法:若要跳转至tabBa ...
- java集合讲解干货集
文章都来自网络,收集后便于查阅. 1.Java 集合系列01之 总体框架 2.Java 集合系列02之 Collection架构 3.Java 集合系列03之 ArrayList详细介绍(源码解析)和 ...
- Quartz Job scheduling 基础实现代码
Quartz 集成在 SpringBoot 中分为 config.task.utils.controller 和 MVC 的三层即 controller.service.dao 和 entity. c ...
- PYTHON 爬虫笔记五:BeautifulSoup库基础用法
知识点一:BeautifulSoup库详解及其基本使用方法 什么是BeautifulSoup 灵活又方便的网页解析库,处理高效,支持多种解析器.利用它不用编写正则表达式即可方便实现网页信息的提取库. ...
- BZOJ 2021 [Usaco2010 Jan]Cheese Towers:dp + 贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2021 题意: John要建一个奶酪塔,高度最大为m. 他有n种奶酪.第i种高度为h[i]( ...
- kvm初体验之六:克隆
目标:克隆vm1到vm1-clone 1. virsh suspend vm1 2. virt-clone --connect qemu:///system --original vm1 --name ...
- jQuery 获取有多个class名的元素
HTML内容: <div class="write-upload"> <p class="write-files old-files"> ...