¿ìËÙÒµÎñͨµÀ

ϵͳѧϰhibernateÖ®ËÄ hibernate¶à¶ÔÒ»¹ØÁªÓ³Éä - ±à³ÌÈëÃÅÍø

×÷Õß ØýÃû¼¼Êõ À´Ô´ NET±à³Ì ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-20

ϵͳѧϰhibernateÖ®ËÄ hibernate¶à¶ÔÒ»¹ØÁªÓ³Éä

ʱ¼ä:2011-01-27 blogjava apple0668

Ò»¡¢¹ØÁªÓ³ÉäµÄ±¾ÖÊ£º

* ½«¹ØÁª¹ØϵӳÉäµ½Êý¾Ý¿â£¬ËùνµÄ¹ØÁª¹ØϵÊǶÔÏóÄ£ÐÍÔÚÄÚ´æÖеÄÒ»¸ö»ò¶à¸öÒýÓÃ

<many-to-one>»áÔÚ¶àµÄÒ»¶Ë¼ÓÈëÒ»¸öÍâ¼ü£¬Ö¸ÏòÒ»µÄÒ»¶Ë£¬Õâ¸öÍâ¼üÊÇÓÉ<many-to-one>

ÖеÄcolumnÊôÐÔ¶¨ÒåµÄ£¬Èç¹ûºöÂÔÁËÕâ¸öÊôÐÔÄÇôĬÈϵÄÍâ¼üÓëʵÌåµÄÊôÐÔÒ»ÖÂ

<many-to-one>±êÇ©µÄ¶¨ÒåʾÀý£º

* <many-to-one name="group" column="groupid"/>

1¡¢UserµÄPOJOÀࣺ

1public class User { 2 3¡¡¡¡private int id; 4 5¡¡¡¡private String name; 6 7¡¡¡¡private Group group; 8//Ê¡ÂÔsetter¡¢getter·½·¨ 9}2¡¢GroupµÄPOJOÀࣺ 1public class Group { 2 3¡¡¡¡private int id; 4 5¡¡¡¡private String name; 6//Ê¡ÂÔsetter¡¢getter·½·¨ 7}

3¡¢UserµÄÓ³ÉäÎļþUser.hbm.xml£º

1<?xml version="1.0"?> 2<!DOCTYPE hibernate-mapping PUBLIC 3¡¡¡¡"-//Hibernate/Hibernate Mapping DTD 3.0//EN" 4¡¡¡¡""> 5<hibernate-mapping> 6¡¡¡¡<class name="com.bjsxt.hibernate.User" table="t_user"> 7¡¡¡¡¡¡¡¡<id name="id"> 8¡¡¡¡¡¡¡¡¡¡¡¡<generator class="native"/> 9¡¡¡¡¡¡¡¡</id> 10¡¡¡¡¡¡¡¡<property name="name"/> 11¡¡¡¡¡¡¡¡ <many-to-one name="group" column="groupid"/> 12¡¡¡¡</class> 13</hibernate-mapping>

4¡¢GroupµÄÓ³ÉäÎļþGroup.hbm.xml£º

1<?xml version="1.0"?> 2<!DOCTYPE hibernate-mapping PUBLIC 3¡¡¡¡"-//Hibernate/Hibernate Mapping DTD 3.0//EN" 4¡¡¡¡""> 5<hibernate-mapping> 6¡¡¡¡<class name="com.bjsxt.hibernate.Group" table="t_group"> 7¡¡¡¡¡¡¡¡<id name="id"> 8¡¡¡¡¡¡¡¡¡¡¡¡<generator class="native"/> 9¡¡¡¡¡¡¡¡</id> 10¡¡¡¡¡¡¡¡<property name="name"/> 11¡¡¡¡</class> 12</hibernate-mapping>

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

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ºÅ