HibernateAnnotations3.2.0CR11.2.1.1.1.1.2.2.Bean2.1.2.2.EJB32.2.1.bean2.2.1.1.(Table)2.2.1.2.2.2.2.2.2.2.1.2.2.2.2.2.2.2.3.()2.2.2.4.2.2..2.2.4.2.2.4.1.2.2.4.2.2.2.4.3.2.2.4.4.2.2.5.Bean2.2.5.1.(One-to-one)2.2.5.2.(Many-to-one)2.2.5.3.2.2.5.4.cascading(Transitivepersistence)2.2.5.5.2.2.6.2.2.7.(secondarytables)2.3.2.3.1.EJBQL/HQL2.3.2.2.4.Hibernate2.4.1.2.4.2.2.4.3.2.4.3.1.2.4.3.2.2.4.3.3.2.4.3.4.2.4.3.5.@Parent2.4.3.6.2.4.4.2.4.5.2.4.5.1.2.4.6.2.4.6.1.2.4.6.2.2.4.7.2.4.8.2.4.9.3.XML3.1.3.1.1.3.1.2.3.1.3.3.1.4.4.Hibernate4.1.4.1.1.4.1.2.4.1.3.4.1.4.4.1.5.4.2.4.2.1.schema4.2.2.Hibernate4.2.3.4.2.4.5.HibernateLucene5.1.LucenePage1of34HibernateAnnotations2010-12-1file://F:\JavaJAR\Hibernate3.3.2\hibernate-annotations-3.4.0.GA\hibernate-annotations...5.1.1.5.1.2.A.WARNING!ThisisatranslatedversionoftheEnglishHibernatereferencedocumentation.Thetranslatedversionmightnotbeuptodate!However,thedifferencesshouldonlybeveryminor.ConsulttheEnglishreferencedocumentationifyouaremissinginformationorencounteratranslationerror.Ifyouliketocontributetoaparticulartranslation,contactusontheHibernatedevelopermailinglist.Translator(s):RedSagaTranslateTeamcaoxg@yahoo.com1.HibernateHibernate://“OpenDoc”“”OpenDocHibernateiBatisSpringWebWork20055HibernateHibernate400Hibernate()HibernateAnnotationicess()icess“”////ORM,Hibernate.Hibernate2.x,XML.Xdoclet,Javadoc.JDKJDK1.5,.IntelliJIDEAEclipse,IDEJDK5.0.,Hibernate,XML.EJB3ORM.EJB3ORMAPIORM.HibernateEntityManagerEJB3.HibernateCoreHibernateAnnotations()EJB3.,EJB3,HibernateCore..HibernatenativeAPIs,,JDBCSQL.HibernateAnnotations(EJB3.0/JSR-220)..ORM,EJB3Hibernate3EJB3..???.EJB3,:Glossary:mochowLiuChangPage2of34HibernateAnnotations2010-12-1file://F:\JavaJAR\Hibernate3.3.2\hibernate-annotations-3.4.0.GA\hibernate-annotations...11.1.HibernateHibernateAnnotations()Hibernate3.2.0.CR2Hibernate3.xHibernatecore3.2.0.CR2JDK5.0JDKXdocletJDK5.0Xdoclet1.2.classpath(IDE)Hibernate3(lib/README.txt)classpathhibernate-annotations.jarlib/ejb3-persistence.jarclasspath5HibernateLucenelucenejarclasspath(wrapper)HibernateUtilHibernateHibernate(helper):packagehello;importorg.hibernate.*;importorg.hibernate.cfg.*;importtest.*;importtest.animals.Dog;publicclassHibernateUtil{privatestaticfinalSessionFactorysessionFactory;static{try{sessionFactory=newAnnotationConfiguration().buildSessionFactory();}catch(Throwableex){//Logexception!thrownewExceptionInInitializerError(ex);}}publicstaticSessiongetSession()throwsHibernateException{returnsessionFactory.openSession();}}AnnotationConfigurationXML(hibernate.cfg.xml)xml:!DOCTYPEhibernate-configurationPUBLIC-//Hibernate/HibernateConfigurationDTD3.0//EN=test.animals/mappingclass=test.Flight/mappingclass=test.Sky/mappingclass=test.Person/mappingclass=test.animals.Dog/mappingresource=test/animals/orm.xml//session-factory/hibernate-configurationhbm.xml(resourceelement)hbmEJB3XML,sessionFactory=newAnnotationConfiguration().addPackage(test.animals)//thefullyqualifiedpackagename.addAnnotatedClass(Flight.class).addAnnotatedClass(Sky.class).addAnnotatedClass(Person.class)Page3of34HibernateAnnotations2010-12-1file://F:\JavaJAR\Hibernate3.3.2\hibernate-annotations-3.4.0.GA\hibernate-annotations....addAnnotatedClass(Dog.class).buildSessionFactory();HibernateEntityManagerHibernateEntityManagerHibernateAPI(hibernate.propertieshibernate.cfg.xmlprogrammaticAPIs)SessionFactorybm.cfg.xml(hbm.xml).hbmhbmhbmhibernate.mapping.precedencehbm,classclass,hbmhbm2Bean2.1.EJB3.0beanHibernate.2.2.EJB3EJB3BeanPOJO.Hibernate.JDK5.0(EJB3XML).,,,,schema,,,..EJB3APIjavax.persistence.*.JDK5IDE(Eclipse,IntelliJIDEANetbeans).(IDEEJB3,EJB3JDK5)JBossEJB3.0HibernateAnnotations.HibernateAnnotations,.2.2.1.beanPOJObean,@Entity:@EntitypublicclassFlightimplementsSerializable{Longid;@IdpublicLonggetId(){returnid;}publicvoidsetId(Longid){this.id=id;}}@Entitybean(POJO),@Idbean..,EJ3,.FlightFlight,id.,,,Hibernatefieldproperty.EJ3,,propertygetter,field..Hibernate@Id@EmbeddedId.2.2.1.1.(Table)@Table,@Tablebean(table),(catalog)schema.@Table,().@Entity@Table(name=tbl_sky)publicclassSkyimplemen