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 库, ...
随机推荐
- 【BZOJ4241】历史研究 分块
[BZOJ4241]历史研究 Description IOI国历史研究的第一人——JOI教授,最近获得了一份被认为是古代IOI国的住民写下的日记.JOI教授为了通过这份日记来研究古代IOI国的生活,开 ...
- 实现RTSP网站微信直播方案EasyNVR(linux版)部署问题之:ERR_CONTENT_LENGTH_MISMATCH
发现问题: 想要优化一下EasyNVR相关功能,内部测试软件,于是在linux系统中部署了一台EasyNVR.当部署好,运行起来发现问题: EasyNVR的配置页面数据出不来. 分析问题: 基于是we ...
- html学习笔记(2)-字母大小写转换练习
主要应用了text-transform属性值: uppercase:所有单词的字母都大写: lowercase:所有单词的字母都小写: capitalize:每个单词的首字母都大写: none:默认值 ...
- python venv虚拟环境
1 目的 给python应用一个独立的运行环境,独立于其它的python应用也独立于系统的python环境. 环境升级不影响其它应用. 避免包冲突. 2 创建方式 2.1 pycharm中创建 pro ...
- maven 手动安装本地jar包
1.需要知道groupId.artifactId.version通过 cmd命令行执行 mvn install:install-file ,比如安装sigar.jar如下: mvn install:i ...
- 编写你的第一个web应用程序1
在shell中运行以下命令来检查django是否已安装及其版本 python -m django --version 如果django已经安装,你应该看到安装的版本号,如果还没有安装,你会看到一个‘n ...
- DLL中导出ANSI和UNICODE函数
模仿window中的DLL导出ANSI和UNICODE版本的函数,使用UNICODE宏来控制使用哪个版本: 在函数实际的执行代码UNICODE版本中,在ANSI函数的版本中只做参数的转换,及ANSI字 ...
- Vue-router进阶、单页面应用(SPA)带来的问题
一 . vue-router 进阶 回顾学过的vue-router,并参考官方文档学习嵌套路由等路由相关知识. 二 . 单页面应用(SPA)带来的问题 1 . 虽然单页面应用有优点 , 但是,如果后端 ...
- iOS开发中集成Reveal
[转]http://blog.devzeng.com/blog/ios-reveal-integrating.html 配置方式一简介有效. Reveal 是一个界面调试工具.使用Reveal,我们可 ...
- js调试笔记
js调试方法很多,今天总结一下最实用的的断点方法: debugger断点 这个很常见,但许多人不知道其实可以添加条件判断 if(something){debugger;} source断点 这个最为常 ...