// 删除配置文件(Books.hbm.xml)的标签(many-to-one)属性(lazy)的话,就不显示下面语句。原因不明
package com.hibernate.entity;
import java.io.Serializable;
public class Publishers implements Serializable {
public int id;
public String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
<?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="com.hibernate.entity.Publishers" table="publishers" catalog="bookshop">
<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" length="16" not-null="true" />
</property>
</class>
</hibernate-mapping>
<?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="com.hibernate.entity.Books" table="Books" catalog="bookshop">
<id name="id" type="java.lang.Integer">
<column name="Id" />
<generator class="native"></generator>
</id>
<property name="title" type="java.lang.String">
<column name="title" length="16" not-null="true"></column>
</property>
<many-to-one name="Publishers" column="PublisherId" class="com.hibernate.entity.Publishers"></many-to-one>
</class>
</hibernate-mapping>
package com.hibernate.entity;
import java.io.Serializable;
public class Books implements Serializable {
private int id;
private Publishers publishers;
public Books(){}
public Publishers getPublishers() {
return publishers;
}
public void setPublishers(Publishers publishers) {
this.publishers = publishers;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
package com;
import org.junit.Test;
import com.hibernate.dao.BaseHibernateDAO;
import com.hibernate.entity.Books;
public class Select extends BaseHibernateDAO {
@Test
public void select() {
Books books = (Books) super.get(Books.class, 4939);
// 删除配置文件(Books.hbm.xml)的标签(many-to-one)属性(lazy)的话,就不显示下面语句。原因不明
System.out.println("name=" + books.getPublishers().getName());
}
}
分享到:
相关推荐
<many-to-one name="systemSpecialtyCode" class="com.hibernate.model.SystemSpecialtyCode" fetch="select" lazy="false"> </many-to-one> <many-to-one name="systemGradeCode" class=...
<one-to-many class="OrderLine"/> </hibernate-mapping>Analogous you can implement the mappings for the Customer entity <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:...
020 <one-to-one>、<many-to-one>单端关联上的 lazy(懒加载)属性 021 继承关联映射 022 component(组件)关联映射 023 复合主键 关联映射 024 其它 关联映射 025 hibernate 悲观锁、乐观锁 026 hibernate 操作树形...
<many-to-one name="purchaseDetails" class="eg.Purchase"/> <many-to-one name="item" class="eg.Item"/> </composite-element> 在查询中,表达组合元素的语法和关联到其他实体的语法是一样的。 8.3. 组件...
<many-to-one name="dept" class="org.wllt.www.po.Dept" fetch="select" cascade ="none" lazy ="proxy"> </many-to-one> </property> </hibernate-mapping> Hibernate映射一对一...
7.5.1. one to many / many to one 7.5.2. one to one 7.5.3. many to many 7.6. More complex association mappings 8. Component Mapping 8.1. Dependent objects 8.2. Collections of dependent objects 8.3. ...
一对多关联(One-To-Many Associations) 14 延迟初始化(延迟加载)(Lazy Initialization) 14 集合排序(Sorted Collections) 14 使用 <idbag> 14 双向关联(Bidirectional Associations) 14 三重关联(Ternary ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 7.6. 更复杂的关联映射 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 7.6. 更复杂的关联映射 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 7.6. 更复杂的关联映射 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) ...
7.4.1. 一对多(one to many) / 多对一(many to one) 7.4.2. 一对一(one to one) 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) 7.5.1. 一对多(one to many) /多对一( many ...
一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 7.6. 更复杂的关联映射 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) 8.2. 在...
* "git fetch" into a lazy clone forgot to fetch base objects that are necessary to complete delta in a thin packfile, which has been corrected. * The filter_data used in the list-objects-filter ...
7.4.1. 一对多(one to many) / 多对一(many to one) 7.4.2. 一对一(one to one) 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) 7.5.1. 一对多(one to many) /多对一( many ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 7.6. 更复杂的关联映射 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) 8.2. 在...
7.4.1. 一对多(one to many) / 多对一(many to one) 7.4.2. 一对一(one to one) 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) 7.5.1. 一对多(one to many) /多对一( many to ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) 8.2. 在集合中出现的依赖对象 ...
一对多(one to many) /多对一( many to one) 8.5.2. 一对一(one to one) 8.5.3. 多对多(many to many) 9. 组件(Component)映射 9.1. 依赖对象(Dependent objects) 9.2. 在集合中出现的依赖对象 ...
The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................
8.5.1. 一对多(one to many) /多对一( many to one) 8.5.2. 一对一(one to one) 8.5.3. 多对多(many to many) 9. 组件(Component)映射 9.1. 依赖对象(Dependent objects) 9.2. 在集合中出现的依赖...