@hainingwyx
2017-11-15T14:48:45.000000Z
字数 1393
阅读 1306
Java
ORM(Object/Relationship Mapping):对象/关系映射
写SQL语句的缺点:
hibernate是可行的ORM框架技术。
其他的ORM技术
1. MyBatis:前身就是iBatis(Apache)
2. Toplink:后被Oracle收购,并重新包装为Oracle AS TopLink
3. EJB:本身是JAVAEE的规范(重量级)
编写Hibernate
配置文件
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><property name="connection.username">root</property><property name="connection.password">root</property><property name="connection.driver_class">com.mysql.jdbc.Driver</property><property name="connection.url">jdbc:mysql://localhost:3306/test</property><property name="dialect">org.hibernate.dialect.MySQLDialect</property><property name="show_sql">true</property><property name="format_sql">true</property><property name="hbm2ddl.auto">create</property><mapping resource="Student.hbm.xml" /></session-factory></hibernate-configuration>
构造持久类
持久化类的设计原则追寻javabeans的设计原则。javabean的四点要求
