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 库, ...
随机推荐
- Git 自己的一些工作中的总结
这个网址很重要:https://gitee.com/progit/2-Git-%E5%9F%BA%E7%A1%80.html#2.4-%E6%92%A4%E6%B6%88%E6%93%8D%E4%BD ...
- a positive definite matrix
https://en.wikipedia.org/wiki/Definite_quadratic_form https://www.math.utah.edu/~zwick/Classes/Fall2 ...
- JAVA中int与String类型的相互转换
Java的int和String类型间互相转换,小功能但是经常用到,下面是几种实现的方法: 字符串类型String转换成整数int 1. int i = Integer.parseInt([String ...
- 【题解】CF891CEnvy
[题解] CF891C Envy 很好玩的一道题.尽管不难,但是调了很久QAQ 考虑克鲁斯卡尔最小生成树的算法,可以发现这些最小树生成的性质: 当生成树所有边的权值都\(\le\)某个$ w$的时刻, ...
- 关于Wix的源代码
Wix的源代码有两种方式可以获得,以3.8为例: 在Release的页面下载wix38-debug.zip 通过SourceCode页面下载,http://wix.codeplex.com/Sourc ...
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
开发中常常需要自己定义Listview,去继承BaseAdapter,在adapter中按照需求进行编写,问题就出现了,可能会发生点击每一个item的时候没有反应,无法获取的焦点. 如果你的自定义Li ...
- linux日志系统介绍 —— syslog(),openlog(),closelog()
函数使用介绍 这里面的三个函数openlog, syslog.closelog是一套系统日志写入接口.另外那个vsyslog和syslog功能一样,仅仅是參数格式不同. 通常.sysl ...
- JS性能优化——加载和执行
JavaScript 在浏览器中的性能,可以认为是开发者所面临得最严重的可用性问题.这个问题因JavaScript的阻塞特性变得复杂, 也就是说当浏览器在执行JavaScript代码时,不能同时做其他 ...
- UVA - 11624 Fire! 【BFS】
题意 有一个人 有一些火 人 在每一秒 可以向 上下左右的空地走 火每秒 也会向 上下左右的空地 蔓延 求 人能不能跑出来 如果能 求最小时间 思路 有一个 坑点 火是 可能有 多处 的 样例中 只有 ...
- (linux)BSP(板上支持包)概述
1. BSP概述 BSP即Board Support Package,板级支持包. 它来源于嵌入式操作系统与硬件无关的设计思想,操作系统被设计为运行在虚拟的硬件平台上. 对于具体的硬件平台,与硬件相关 ...