快速业务通道

hibernate3学习笔记(十六)|容器映射 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-19
on found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/Java/MyEclipse%206.0/workspace/hb3demo/ehcache-1.2.3.jar!/ehcache-failsafe.xml13:32:16,609 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.13:32:16,640 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.Hibernate: insert into user (name) values (?)Hibernate: insert into user (name) values (?)Hibernate: insert into item (id, cid, name) values (?, ?, ?)Hibernate: insert into item (id, cid, name) values (?, ?, ?)Hibernate: insert into item (id, cid, name) values (?, ?, ?)Hibernate: insert into item (id, cid, name) values (?, ?, ?)Hibernate: select user0_.id as id0_0_, user0_.name as name0_0_ from user user0_ where user0_.id=?Hibernate: select items0_.id as id0_, items0_.name as name0_, items0_.cid as cid0_ from item items0_ where items0_.id=?Hibernate: delete from item where cid=?

4.Map映射

DDL:

1.CREATE TABLE user (2.    id INT(11) NOT NULL auto_increment PRIMARY KEY,3.    name VARCHAR(100) NOT NULL default ''''4.);5.6.CREATE TABLE item (7.    id INT(11) NOT NULL,8.    name VARCHAR(100) NOT NULL,9.    price decimal(10,2) NOT NULL10.);

User.java

1.package com.hb3.pack_14.model;2.3.import java.math.BigDecimal;4.import java.util.Map;5.6.public class User {7.
8.    private Integer id;9.    private String name;10.    private Map<String, BigDecimal> items;11.
12.    public User() {13.    }14.
15.    public Integer getId() {16.        return id;17.    }18.    public void setId(Integer id) {19.        this.id = id;20.    }21.    public String getName() {22.        return name;23.    }24.    public void setName(String name) {25.        this.name = name;26.    }27.    public Map<String, BigDecimal> getItems() {28.        return items;29.    }30.    public void setItems(Map<String, BigDecimal> items) {31.        this.items = items;32.    }33.    public void addItem(String key, BigDecimal value) {34.        items.put(key, value);35.    }36.    public void removeItem(String key) {37.        items.remove(key);38.    }39.}

hibernate3学习笔记(十六)|容器映射(10)

时间:2011-02-03 csdn博客 沈斌

User.hbm.xml:

1.<?xml version="1.0" encoding="utf-8"?>2.<!DOCTYPE hibernate-mapping3.    PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"4.    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
5.
6.<hibernate-mapping>7.
8.    <class name="com.hb3.pack_14.model.User" table="user">9.10.        <id name="id" column="id" type="java.lang.Integer">11.            <generator class="native"/>12.        </id>13.14.        <property name="name" column="name" type="java.lang.String"/>15.16.        <map name="items" table="ite

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号