mapping files for POJO classes and databases *.hbm.xml
The mapping between the Pojo class and the relational database can be defined with an XML document.
The map file has the extension. hbm.xml
Hibernate will generate various SQL statements based on this mapping file at run time
With the Pojo clas
Preface:Object-Relational mapping (ORM), which is a technology to solve the mismatch between object-oriented and relational databases, is essentially the conversion of a database from one form to another, as a result of the development of object-oriented software development methods. ORM automatically persists the exclusive use of a Java program into a relational database by using metadata that describes the mappi
In hibernate, there are usually two kinds of configuration object relationship mapping relationship, one is based on XML, the other is based on annotation annotation, cooked words, radish green vegetables, can have love, everyone has their favorite configuration, I tried these two ways, Find the way to use annotation can be more brief, so here is a simple record under the annotation to configure the various
with the step-by-step practice of hibernate , it is necessary to make a summary, so that you can make your ideas clearer! I. Knowledge generalization The whole idea of mind mapping is:second, the corresponding structure diagram and implementationNBSP;NBSP;NBSP;NBSP; Span lang= "ZH-CN" style= "Font-family:calibri" >NBSP;NBSP; (i) One-way, single-connection mapping
ig.setweight (), session.save (pig); Bird bird=new Bird (); Bird.setname ("Xiaoniaoniao"); Bird.setsex (true); Bird.setheight (+); Session.save (Bird); Session.gettransaction (). commit ();} catch (Exception e) {e.printstacktrace (); Session.gettransaction (). rollback (); Finally{hibernateutils.closesession (session);}}2.2 polymorphic Queries--get and HQLThe first few articles have discussed the basic query methods, just use the load and get methods, where the focus is on polymorphic queries.
Mapping TypeWhen you prepare a Hibernate mapping file, we have seen you map the Java data type to the RDBMS data format. The types that have been declared to be used in the mapping file are not Java data types, nor are they SQL database types. This type is known as the Hibernate
The previous several are introduced with the configuration file to implement the entity class to the database table mapping, this way is more troublesome, each Pojo class need to write a corresponding *.hbm.xml, undoubtedly increased a lot of code, but also has the advantage is conducive to maintenance, in order to facilitate the development, Hibernate also provides an annotated way to configure the
When hibernate encounters a cocould not parse mapping document from resource error, parsemappingStart of object relationship ing: the class element indicates the ing between the class and the table in the database.The name attribute specifies the full Java qualified name of the persistence class (or interface;The table attribute specifies the name of the database table to be mapped. If it is omitted, the na
Many-to-many relationships (student student, course course)The definition of student class and the configuration of HBM files are as follows1 Public class Student {2 Private int ID; 3 Private String name; 4 Private New Hashset(); 5 }1 XML version= "1.0" encoding= "UTF-8"?>2 DOCTYPE hibernate-mapping Public3 "-//hibernate/
An ORM, the full name (objectrelational Mapping), is the object-relational mapping. The idea of ORM is to map the data of tables in a relational database into objects as objects, so that developers can translate the operations of the database into operations on those objects. Hibernate is the realization of this idea, to facilitate the development of people with
Hibernate (hereinafter referred to as Hiber) the first part of the study was finally over. The process of learning, summed up some experience and learning notes, special take out and share with you, because I have limited capacity, can not be proficient in hiber, so also please identify, if found anything wrong, also hope feel free, thank you for your treatise. In the process of learning hiber, I bought a book: "In Simple
ORM Introduction to the advanced ORM ORM advanced Hibernate Introduction and FramingORM the advanced Hibernate the three main objectsAnalysis of three states of objects in ORM advanced Hibernate One -to-one relationship mapping in ORM advanced Hibernate
Hibernate Mapping file in detail2010-09-02 19:03:33| Category: Hibernate learning | Report | Font size Subscription The mappings between Hibernate's persistence classes and relational databases are usually defined with an XML document. The document establishes a one by one mapping between a persisted class and a
Create a Web project, use Hibernate, create an entity class in a project it's too much trouble to waste time, now teach you how to use MyEclipse to automatically generate Hibernate mapping files and entity classesMethod/Step
Create a database, create the appropriate table
Click on the icon to select MyEclipse datebase Explorer
Right-click an empty area, c
(slightly)3.3 Importing prototypes• Import the artwork into the project by writing the prototype page. The artwork provides HTML pages, and you need to modify the JSP pages yourself.4.4 Package Structure Overall format: COM.ITHEIMA.CRM. module NAME. Package Structure For example:Com.itheima.crm.staff.daoCom.itheima.crm.staff.dao.implCom.itheima.crm.staff.serviceCom.itheima.crm.staff.servcie.implCom.itheima.crm.staff.web.actionCom.itheima.crm.staff.domainCom.itheima.crm.utilsOne course categor
database information, but also configures the mapping file so that the mapping file can be imported into the database through the tool class.Tool Class This is our own hand-written tool class. Used to map an entity class into a table. and save to the database.Import org.hibernate.cfg.configuration;import org.hibernate.tool.hbm2ddl.schemaexport;/** * Generate DDL for HBM * @author Administrator * */public
As an ORM framework, hibernate certainly needs to meet our need to relate tables to tables. The implementation of Hibernate in association method is very simple. Let's take a look at a one-to-one approach:Not much to say, we go directly to the code:Two entity classes, Tuser and Tpassport:
public class TUser implements serializable{
private static final long serialversionuid = 1L;
private int i
The base of object relation mapping of Hibernate
1. Object Relational Mapping Basics1 when the session of the Hibernate executes the Save (arg0), update (ARG0), or Saveorupdate (arg0) method, the GetXXX () method is invoked when the sessions execute get (), load () and the Find () method invokes the Setxxx
The entity class refers to the ordinary pojo,hibernate does not know which entity class corresponds to the database of which table, so also need to configure, the common way is the *.hbm.xml file [configuration and @ annotation configuration, here describes the former detailed properties:XML version= "1.0"?>DOCTYPE hibernate-mapping Public "-//
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.