08 2012 档案
摘要:OSCache可以支持中央缓存要想支持缓存hibernate.cfg.xml应该做如下配置:<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hiberna
阅读全文
摘要:1、Hibernate对于集合不区分空集和null,也就是说下面这两种情况在Hibernate里面是一样的:Collection c = new ArrayList();//c != nullCollection c1 = null;
阅读全文
摘要:类与表的关系:*************Employee.java*************package blog.hibernate.domain; public class Employee { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { re...
阅读全文
摘要:类和表的关系:单独使用<subclass/>元素的类会和父类在同一张表里;使用<subclass><join></join></subclass>这两个元素的类会单独占一个表。*************Employee.java*************package blog.hibernate.domain; public class Employee { private int id; private String name; public int getId() { return id; } public void setI.
阅读全文
摘要:类与表的关系:*************Employee.java*************package blog.hibernate.domain; public class Employee { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { re...
阅读全文
摘要:类与表的关系:*************Employee.java*************package blog.hibernate.domain; public class Employee { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { re...
阅读全文
摘要:***************Student.java***************package blog.hibernate.domain; import java.util.ArrayList;
import java.util.List; public class Student { private int id; private String name; private List<Teacher> teachers = new ArrayList<Teacher>(); public List<Teacher> getTeachers() {
..
阅读全文
摘要:****************hibernate.cfg.xml***************<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hiber
阅读全文
摘要:***************Teacher.java***************package blog.hibernate.domain; import java.util.HashMap;
import java.util.List;
import java.util.Map; public class Teacher { private int id; private String name; private String course; private Map<String, Student> students = new HashMap<S...
阅读全文
摘要:今天我们介绍相关HTML5的参考手册,演讲稿,电子书和教程。HTML5是新兴的web技术,虽然不是完全的新技术但是已经有很多的相关文章介绍HTML5,特别是当我们谈论HTML5将成为Flash的替代品。现代浏览器的快速开发已经刺激用户相应发展。毫无质疑,现在是学习HTML5的好时间,大多数的公司例如Google,Youtube,Facebook都已经开始使用HTML5来建站了。51CTO推荐专题:HTML 5 下一代Web开发标准详解这篇文章我们将介绍最好的HTML5参考手册,电子书,教程。友情提示:你最好阅读一些我们以前的HTML5文章!希望大家喜欢!参考手册,演讲稿,电子书第一部分我们将介
阅读全文
摘要:***************public void Map_Add() { Session session = null; Transaction tx = null; try { City city1 = new City(); city1.setName("中国·唐山"); city1.setPostcode("063009"); City city2 = new City(); city2.setName("中国·天...
阅读全文
摘要:*************City.java************package blog.hibernate.domain; public class City { private int id; private String name; private String postcode; private Nation nation; public String getPostcode() { return postcode; } public void setPostcode(String postcode) ...
阅读全文
摘要:0.快捷键================================================================================编辑:Ctrl+Shift+L显示所有快捷键Ctrl+K参照选中的词(Word)快速定位到下一个Ctrl+Shift+K参照选中的词(Word)快速定位到上一个Ctrl+O快速显示OutLineCtrl+T快速显示当前类的继承结构Ctrl+Shift+X把选中文本全部改为大写Ctrl+Shift+Y把选中文本全部改为小写Ctrl+Shift+F按照当前的配置文件格式化源代码Ctrl+L弹出行定位框以便定位到某一行Ctrl+Nu
阅读全文
摘要:1、java.util.Set ----------- set 集合无顺序2、java.util.List -----------list 集合有顺序 java.util.List -----------bag集合无顺序3、java.util.Map ------------map 映射4、数组--array -------------有顺序List ---------bag
阅读全文
摘要:*********************Name.java*********************package blog.hibernate.domain; public class Name { private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String fristName) { this.firstName = fristName; } public ...
阅读全文
摘要:*****************Teacher.java****************package blog.hibernate.domain; import java.util.Set; public class Teacher { private int id; private String name; private Set<Student> students; public int getId() { return id; } public void setId(int id) { this.id = id; } public String get...
阅读全文
摘要:*****************IdCard.hbm.xml*****************<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="blog.hiber
阅读全文
摘要:********************Person.java主对像********************package blog.hibernate.domain; public class Person { private int id; private String name; private IdCard idCard; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name;...
阅读全文
摘要:对象模型的设计:*********************User.java********************package blog.hibernate.domain; import java.util.Date; public class User { private int id; private String name; private Date birthday; private Department depart; public Department getDepart() { return depart; } public void setDepa...
阅读全文
摘要:***************************HibernateUtil.java***************************package blog.hibernate; import java.util.Date;
import java.util.List; import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Sessi..
阅读全文
摘要:1、在oracle中user为关键字,所以如果mysql中有一个名为mysql的表的话,再转到oracle上时会出错这时可以更改表名如:tuser或者将user用反引号扣起来`user`,反引号就是Tab键上面的那个键。
阅读全文
摘要:update方法主要用于处于脱管态的数据的更新。处于持久态的数据的更改会被hibernate检测到,会将更改写入数据库。
阅读全文
摘要:session.save()在没有开启事务的状态下,会向数据库插入数据,但之后又会回滚,因为没有开启事务。而session.persist()方法中在没有开启事务的状态下,不会插入数据,这就是他们的区别。
阅读全文
摘要:public static void main(String[] args) { User user = new User(); user.setName("test3"); user.setBirthday(new Date()); try { addObject(user); User user1 = getUser(user.getId()); System.out.println("user1" + user1.getClass().getName()); System.out.println(user.getId()); System.o...
阅读全文
摘要:Class.forName(className).newInstance()需要类有一个默认的构造方法
阅读全文
摘要:show create table Table_Name;查看创建表的DMLshow engines;查看支持的引擎
阅读全文
摘要:jdbc 默认提交事物hibernate 默认不提交事物所以在进行增删改时需要主动提交事务如果使用mysql和hibernate进行增删改并且没有提交事务,但数据还是被保存进了数据库,这时应该看查看数据库所使用的引擎,如果是ISAM和MyISAM引擎的话,是不支持事务的,这时提交的数据无需事务也能保存。而InnoDB则需要提交事务才能保存。
阅读全文
摘要:************************hibernate.cfg.xml***********************<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quo
阅读全文
摘要:beans.xml:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="ht
阅读全文
摘要:spring对于事务异常的处理//unchecked 运行期Exception spring默认会进行事务回滚 比如:RuntimeException//checked 用户Exception spring默认不会进行事务回滚 比如:Exception如何改变spring的这种默认事务行为?可以通过在方法上添加@Transactional(noRollbackFor=RuntimeException.class)让spring对于RuntimeException不回滚事务添加@Transactional(RollbackFor=Exception.class)让spring对于Exceptio
阅读全文
摘要:************************beans.xml************************<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframe
阅读全文
摘要:注解方式*******************beans.xml*******************<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.o
阅读全文
摘要:ctrl+shift+f:格式化源码ctrl+shift+o:去除无用的引用f3:定位到类源码f4:查看类层次图
阅读全文
摘要:spring中aop功能的实现实际上是用cglib和jdk实现的,如果目标对象实现了接口那么用的是Jdk的方式实现,如果目标对象没有实现接口那么用的是cglib的方式实现。*******************PersonService.java*******************package blog.service; public interface PersonService { public String save(String name); public String update(String name,Integer userId); }
*************...
阅读全文
摘要:************beans.xml************<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context&
阅读全文
摘要:@Autowired默认按类型装配,它有一个required属性,默认为true,意思是这个字段或属性必须被装配,否则会报字段或属性装配异常,如果required设为false则可以将此字段或属性设置为null@Qualifier("personDao") 这个注解和@Autowired一起使用表示按名称进行查找@Autowired(required=true) @Qualifier("personDao")
阅读全文