Map the class to the database with Hibernate

xiaoxiao2021-03-06  72

Map the class to the database with Hibernate

// sessionFactory is the concept of Hibernate, corresponding to a data store, if there are multiple databases, you can create multiple XML configuration files, and create multiple // CONFIGURATION and SESSIONFAACTORY objects in your program.

false false net.sf.hibernate.diaalect.racle9DiaLect Oracle.jdbc.driver.OracleDriver JDBC: Oracle: Thin: @ 111.11.1.7: 1521: LAB Lab lab // below the first mapping element For example, it declares that mLab.hbm.xml is a mapping file, corresponding to the persistent class MLAB, which maps the Java classes of the Pu // to the database table ======= ============================================================================================================================================================================================================= ============================================================================================================================================================================================================= // This text is saved in the LabForm / Common / HBM / Directory, which contains the metadata required for object / relationship mapping.

/ ** Each persistence class requires an identity attribute, this property is used to distinguish Persistence object: If mlaba.getseqid (). Equals (mLabb.getSeqID ()) The result is * True, the two objects are the same. This concept is called the database identity. * Specify the SEQID field of the MLAB table as the primary key of the table, store the generated identifier * / MLAB_S

========================== ============================================================================================================================================================================================================= ========================================================================================================================================================================================================================================== #

Public class mlab imports serializable {// seqid is a special property that represents this class's database identifier (primary key), private int seqid; private intens; private string roomID; // full constructor public mlab (int SEQID, INT Score, string roomid) {this.seqid = seqid; this.score = score; this.roomid = roomID;

// default constructor public mLab () {}

Public int getseqid () {return this.seqid;}

Public void setseqid (int seqid) {this.seqid = seqid;}

Public int getscore () {return this.score;}

Public void setscore (int score) {this.score = score;}

Public string getroomid () {return this.roomID;

Public void setroom {this.roomid = roomid;}}

转载请注明原文地址:https://www.9cbs.com/read-90999.html

New Post(0)