ϵͳѧϰhibernateÖ®Áù£ºÒ»¶ÔÒ»Íâ¼ü¹ØÁªÓ³ÉäË«Ïò¹ØÁª - ±à³ÌÈëÃÅÍø
ϵͳѧϰhibernateÖ®Áù£ºÒ»¶ÔÒ»Íâ¼ü¹ØÁªÓ³ÉäË«Ïò¹ØÁªÊ±¼ä:2011-08-26hibernateÒ»¶ÔһΨһÍâ¼ü¹ØÁªÓ³É䣨˫Ïò¹ØÁªPerson<---->idcard£© Ò»¶ÔһΨһÍâ¼ü¹ØÁªË«Ïò£¬ÐèÒªÔÚÁíÒ»¶Ë£¨idcard£©£¬Ìí¼Ó<one-to-one>±êÇ©£¬Ö¸Ê¾hibernateÈçºÎ¼ÓÔØ Æä¹ØÁª¶ÔÏó£¬Ä¬Èϸù¾ÝÖ÷¼ü¼ÓÔØperson£¬Íâ¼ü¹ØÁªÓ³ÉäÖУ¬ÒòΪÁ½¸öʵÌå²ÉÓõÄÊÇpersonµÄÍâ¼üά»¤µÄ¹Øϵ£¬ ËùÒÔ²»ÄÜÖ¸¶¨Ö÷¼ü¼ÓÔØperson£¬¶øÒª¸ù¾ÝpersonµÄÍâ¼ü¼ÓÔØ£¬ËùÒÔ²ÉÓÃÈçÏÂÓ³É䷽ʽ£º <one-to-one name="person" property-ref="idCard"/> 1¡¢PersonµÄPOJOÀࣺ 1public class Person {23¡¡¡¡private int id;45¡¡¡¡private String name;67¡¡¡¡private IdCard idCard;8//Ê¡ÂÔsetter¡¢getter·½·¨9} 2¡¢IdCardµÄPOJOÀࣺ 1public class IdCard {23¡¡¡¡private int id;45¡¡¡¡private String cardNo;67¡¡¡¡private Person person;8//Ê¡ÂÔsetter¡¢getter·½·¨9} ϵͳѧϰhibernateÖ®Áù£ºÒ»¶ÔÒ»Íâ¼ü¹ØÁªÓ³ÉäË«Ïò¹ØÁª(2)ʱ¼ä:2011-08-263¡¢PersonµÄÓ³ÉäÎļþPerson.hbm.xml 1<?xml version="1.0"?>2<!DOCTYPE hibernate-mapping PUBLIC3¡¡¡¡"-//Hibernate/Hibernate Mapping DTD 3.0//EN"4¡¡¡¡"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">5<hibernate-mapping>6¡¡¡¡<class name="org.apple.hibernate.Person" table="t_person">7¡¡¡¡¡¡¡¡<id name="id">8¡¡¡¡¡¡¡¡¡¡¡¡<generator class="native"/>9¡¡¡¡¡¡¡¡</id>10¡¡¡¡¡¡¡¡<property name="name"/>11¡¡¡¡¡¡¡¡<many-to-one name="idCard" unique="true"/>12¡¡¡¡</class>13</hibernate-mapping> 4¡¢IdCardµÄÓ³ÉäÎļþIdCard.hbm.xml 1<?xml version="1.0"?>2<!DOCTYPE hibernate-mapping PUBLIC3¡¡¡¡"-//Hibernate/Hibernate Mapping DTD 3.0//EN"4¡¡¡¡"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">5<hibernate-mapping>6¡¡¡¡<class name="org.apple.hibernate.IdCard" table="t_idcard">7¡¡¡¡¡¡¡¡<id name="id">8¡¡¡¡¡¡¡¡¡¡¡¡<generator class="native"/>9¡¡¡¡¡¡¡¡</id>10¡¡¡¡¡¡¡¡<property name="cardNo"/>11¡¡¡¡¡¡¡¡<one-to-one name="person" property-ref="idCard"/>12¡¡¡¡</class>13</hibernate-mapping> |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |
- java¼S?×hÇÔòwindowsºÉÌñÀÇÓÉ×hxCopy - ˆ@š£Ã؉¯Àû
- 15 ·Ç³£ÓÐȤµÄ CSS3 ʾÀý
- PhotoshopºÏ³É½Ì³Ì:ÖÆ×÷±¼³ÛÆû³µÍøÂç¹ã¸æ
- linux ÈíRAIDͼ½â½Ì³Ì
- ÔÚApache GeronimoÖв¿ÊðWeb·þÎñ - ±à³ÌÈëÃÅÍø
- ÍøÂç·Óɼ¼Êõ¼°ÔËÓÃ
- PSÇáËÉÖÆ×÷÷ÈÁ¦ÎÞÏÞµÄË®µ×³¡¾°
- Photoshopµ÷É«½Ì³Ì£º¾ªÑÞÃÀÅ®
- PSÕÕƬµ÷É«½Ì³Ì:Ä£·ÂEEÉ«µ÷·ç¾°ÕÕƬ
- Linux×ÀÃæ°æºáÆÀ£ºËÄ¡¢SuSE Linux Enterprise Desktop 10 SP1