Dog.javapackage gpf;public class Dog {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}Dog.hbm.xml<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="gpf.Dog" table="Dog">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="native"></generator>
</id>
<property name="name" type="java.lang.String">
<column name="name"/>
</property>
</class>
</hibernate-mapping>hibernate.cfg.xml<?xml version='1.0' encoding='utf-8'?>
<!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.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="format_sql">true</property>
<property name="show_sql">true</property> <mapping resource="gpf/Dog.hbm.xml"/>
</session-factory>
</hibernate-configuration>测试类Test.javapublic class Test {
private Session session = new AnnotationConfiguration().configure().buildSessionFactory().getCurrentSession();
@org.junit.Test
public void test(){
session.beginTransaction();
Query query = session.createQuery("from Dog");
Iterator<Dog> iterator = query.iterate();
session.getTransaction().commit();
}
请问第一次查询打印出来的sql语句不是应该是分步的吗,为什么我每次运行都只是发出一个select语句
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}Dog.hbm.xml<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="gpf.Dog" table="Dog">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="native"></generator>
</id>
<property name="name" type="java.lang.String">
<column name="name"/>
</property>
</class>
</hibernate-mapping>hibernate.cfg.xml<?xml version='1.0' encoding='utf-8'?>
<!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.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="format_sql">true</property>
<property name="show_sql">true</property> <mapping resource="gpf/Dog.hbm.xml"/>
</session-factory>
</hibernate-configuration>测试类Test.javapublic class Test {
private Session session = new AnnotationConfiguration().configure().buildSessionFactory().getCurrentSession();
@org.junit.Test
public void test(){
session.beginTransaction();
Query query = session.createQuery("from Dog");
Iterator<Dog> iterator = query.iterate();
session.getTransaction().commit();
}
请问第一次查询打印出来的sql语句不是应该是分步的吗,为什么我每次运行都只是发出一个select语句
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货