欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解Java的Hibernate框架中的List映射表與Bag映射

 更新時(shí)間:2015年12月18日 08:54:06   投稿:goldensun  
這篇文章主要介紹了Java的Hibernate框架中的List映射表與Bag映射,Hibernate是Java的SSH三大web開發(fā)框架之一,需要的朋友可以參考下

List映射表
List列表是一個(gè)java集合存儲(chǔ)在序列中的元素,并允許重復(fù)的元素。此接口的用戶可以精確地控制,其中列表中的每個(gè)元素插入。用戶可以通過他們的整數(shù)索引訪問元素,并搜索列表中的元素。更正式地說,列表通常允許對(duì)元素e1和e2,使得e1.equals(e2),它們通常允許多個(gè)null元素,如果他們?cè)试S的null元素。

List列表被映射在該映射表中的<list>元素,并將java.util.ArrayList中初始化。

定義RDBMS表:
考慮一個(gè)情況,需要員工記錄存儲(chǔ)在EMPLOYEE表,將有以下結(jié)構(gòu):

create table EMPLOYEE (
  id INT NOT NULL auto_increment,
  first_name VARCHAR(20) default NULL,
  last_name VARCHAR(20) default NULL,
  salary   INT default NULL,
  PRIMARY KEY (id)
);

此外,假設(shè)每個(gè)員工都可以有一個(gè)或多個(gè)與他/她相關(guān)的證書。List集合映射需要在一個(gè)集合表的索引列。索引列定義集合中的元素的位置。因此,我們將存儲(chǔ)證書的相關(guān)信息在一個(gè)單獨(dú)的表,該表具有以下結(jié)構(gòu):

create table CERTIFICATE (
  id INT NOT NULL auto_increment,
  certificate_name VARCHAR(30) default NULL,
  idx INT default NULL, 
  employee_id INT default NULL,
  PRIMARY KEY (id)
);

將有一個(gè)對(duì)多( one-to-many)的EMPLOYEE和證書對(duì)象之間的關(guān)系。

定義POJO類:
讓我們實(shí)現(xiàn)一個(gè)POJO類員工將被用于保存與EMPLOYEE表中的對(duì)象和有證書的列表變量的集合。

import java.util.*;

public class Employee {
  private int id;
  private String firstName; 
  private String lastName;  
  private int salary;
  private List certificates;

  public Employee() {}
  public Employee(String fname, String lname, int salary) {
   this.firstName = fname;
   this.lastName = lname;
   this.salary = salary;
  }
  public int getId() {
   return id;
  }
  public void setId( int id ) {
   this.id = id;
  }
  public String getFirstName() {
   return firstName;
  }
  public void setFirstName( String first_name ) {
   this.firstName = first_name;
  }
  public String getLastName() {
   return lastName;
  }
  public void setLastName( String last_name ) {
   this.lastName = last_name;
  }
  public int getSalary() {
   return salary;
  }
  public void setSalary( int salary ) {
   this.salary = salary;
  }

  public List getCertificates() {
   return certificates;
  }
  public void setCertificates( List certificates ) {
   this.certificates = certificates;
  }
}

我們需要相應(yīng)的證書表定義另一個(gè)POJO類,這樣的證書對(duì)象可以存儲(chǔ)和檢索到的證書表。

public class Certificate{
  private int id;
  private String name; 

  public Certificate() {}
  public Certificate(String name) {
   this.name = name;
  }
  public int getId() {
   return id;
  }
  public void setId( int id ) {
   this.id = id;
  }
  public String getName() {
   return name;
  }
  public void setName( String name ) {
   this.name = name;
  }
}

定義Hibernate映射文件:
讓我們開發(fā)指定Hibernate如何定義的類映射到數(shù)據(jù)庫表的映射文件。<list>元素將被用來定義使用List集合的規(guī)則。表的索引是整數(shù)類型總是和使用<list-index>元素定義映射。

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
 "-//Hibernate/Hibernate Mapping DTD//EN"
 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping>
  <class name="Employee" table="EMPLOYEE">
   <meta attribute="class-description">
     This class contains the employee detail. 
   </meta>
   <id name="id" type="int" column="id">
     <generator class="native"/>
   </id>
   <list name="certificates" cascade="all">
     <key column="employee_id"/>
     <list-index column="idx"/>
     <one-to-many class="Certificate"/>
   </list>
   <property name="firstName" column="first_name" type="string"/>
   <property name="lastName" column="last_name" type="string"/>
   <property name="salary" column="salary" type="int"/>
  </class>

  <class name="Certificate" table="CERTIFICATE">
   <meta attribute="class-description">
     This class contains the certificate records. 
   </meta>
   <id name="id" type="int" column="id">
     <generator class="native"/>
   </id>
   <property name="name" column="certificate_name" type="string"/>
  </class>

</hibernate-mapping>

應(yīng)該保存的映射文件中的格式<classname>.hbm.xml。我們保存我們的映射文件中的文件Employee.hbm.xml。你已經(jīng)熟悉了大部分的映射細(xì)節(jié),映射文件中的所有元素:

映射文檔是具有<hibernate-mapping>為對(duì)應(yīng)于每一個(gè)類包含2個(gè)<class>元素的根元素的XML文檔。

<class>元素被用于定義數(shù)據(jù)庫表從一個(gè)Java類特定的映射。 Java類名指定使用class元素的name屬性和使用表屬性數(shù)據(jù)庫表名指定。

<meta>元素是可選元素,可以用來創(chuàng)建類的描述。

<id>元素映射在類中的唯一ID屬性到數(shù)據(jù)庫表的主鍵。 id元素的name屬性是指屬性的類和column屬性是指在數(shù)據(jù)庫表中的列。 type屬性保存了Hibernate映射類型,這種類型的映射將會(huì)從Java轉(zhuǎn)換為SQL數(shù)據(jù)類型。

id元素內(nèi)的<generator>元素被用來自動(dòng)生成的主鍵值。將生成元素的class屬性設(shè)置為原生讓Hibernate拿起無論是identity,sequence或者h(yuǎn)ilo中的算法來創(chuàng)建主鍵根據(jù)底層數(shù)據(jù)庫的支持能力。

<property>元素用于一個(gè)Java類的屬性映射到數(shù)據(jù)庫表中的列。元素的name屬性是指屬性的類和column屬性是指在數(shù)據(jù)庫表中的列。 type屬性保存了Hibernate映射類型,這種類型的映射將會(huì)從Java轉(zhuǎn)換為SQL數(shù)據(jù)類型。

<list>元素用于設(shè)置證書和Employee類之間的關(guān)系。我們使用cascade屬性中<list>元素來告訴Hibernate來保存證書的對(duì)象,同時(shí)為Employee對(duì)象。 name屬性被設(shè)置為在父類中定義的Listvariable,在我們的情況下,它是證書。

<key>元素是包含外鍵的父對(duì)象,即在證書表中的列。即,表EMPLOYEE。

<list-index>元素定義用于保持元件的位置,并與在該集合表的索引列映射。持久性列表的索引從零開始。你可以改變這一點(diǎn),例如,在你的映射<list-index base="1".../>。

<one-to-many>元素表示一個(gè)Employee對(duì)象涉及到很多證書的對(duì)象,并因此,證書對(duì)象必須有與之勞動(dòng)者家長有關(guān)。您可以根據(jù)您的需要使用任何和<one-to-one>,<many-to-one>進(jìn)行或<many-to-many>這個(gè)元素。如果我們改變了這個(gè)例子使用一個(gè)many-to-many的關(guān)系,我們需要一個(gè)關(guān)聯(lián)表到父和子對(duì)象之間的映射。

創(chuàng)建應(yīng)用程序類:
最后,我們將創(chuàng)建應(yīng)用程序類的main()方法來運(yùn)行應(yīng)用程序。我們將使用這個(gè)應(yīng)用程序,以節(jié)省一些員工的記錄連同的證書,然后我們將申請(qǐng)CRUD操作上的記錄。

import java.util.*;
 
import org.hibernate.HibernateException; 
import org.hibernate.Session; 
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class ManageEmployee {
  private static SessionFactory factory; 
  public static void main(String[] args) {
   try{
     factory = new Configuration().configure().buildSessionFactory();
   }catch (Throwable ex) { 
     System.err.println("Failed to create sessionFactory object." + ex);
     throw new ExceptionInInitializerError(ex); 
   }
   ManageEmployee ME = new ManageEmployee();
   /* Let us have a set of certificates for the first employee */
   ArrayList set1 = new ArrayList();
   set1.add(new Certificate("MCA"));
   set1.add(new Certificate("MBA"));
   set1.add(new Certificate("PMP"));
   
   /* Add employee records in the database */
   Integer empID1 = ME.addEmployee("Manoj", "Kumar", 4000, set1);

   /* Another set of certificates for the second employee */
   ArrayList set2 = new ArrayList();
   set2.add(new Certificate("BCA"));
   set2.add(new Certificate("BA"));

   /* Add another employee record in the database */
   Integer empID2 = ME.addEmployee("Dilip", "Kumar", 3000, set2);

   /* List down all the employees */
   ME.listEmployees();

   /* Update employee's salary records */
   ME.updateEmployee(empID1, 5000);

   /* Delete an employee from the database */
   ME.deleteEmployee(empID2);

   /* List down all the employees */
   ME.listEmployees();

  }

  /* Method to add an employee record in the database */
  public Integer addEmployee(String fname, String lname, 
                   int salary, ArrayList cert){
   Session session = factory.openSession();
   Transaction tx = null;
   Integer employeeID = null;
   try{
     tx = session.beginTransaction();
     Employee employee = new Employee(fname, lname, salary);
     employee.setCertificates(cert);
     employeeID = (Integer) session.save(employee); 
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
   return employeeID;
  }

  /* Method to list all the employees detail */
  public void listEmployees( ){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     List employees = session.createQuery("FROM Employee").list(); 
     for (Iterator iterator1 = 
              employees.iterator(); iterator1.hasNext();){
      Employee employee = (Employee) iterator1.next(); 
      System.out.print("First Name: " + employee.getFirstName()); 
      System.out.print(" Last Name: " + employee.getLastName()); 
      System.out.println(" Salary: " + employee.getSalary());
      List certificates = employee.getCertificates();
      for (Iterator iterator2 = 
             certificates.iterator(); iterator2.hasNext();){
         Certificate certName = (Certificate) iterator2.next(); 
         System.out.println("Certificate: " + certName.getName()); 
      }
     }
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
  /* Method to update salary for an employee */
  public void updateEmployee(Integer EmployeeID, int salary ){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     Employee employee = 
          (Employee)session.get(Employee.class, EmployeeID); 
     employee.setSalary( salary );
     session.update(employee);
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
  /* Method to delete an employee from the records */
  public void deleteEmployee(Integer EmployeeID){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     Employee employee = 
          (Employee)session.get(Employee.class, EmployeeID); 
     session.delete(employee); 
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
}

編譯和執(zhí)行:
下面是步驟來編譯并運(yùn)行上述應(yīng)用程序。請(qǐng)確保您已在進(jìn)行的編譯和執(zhí)行之前,適當(dāng)?shù)卦O(shè)置PATH和CLASSPATH。

  • 創(chuàng)建hibernate.cfg.xml配置文件中配置章節(jié)解釋。
  • 創(chuàng)建Employee.hbm.xml映射文件,如上圖所示。
  • 創(chuàng)建Employee.java源文件,如上圖所示,并編譯它.
  • 創(chuàng)建Certificate.java源文件,如上圖所示,并編譯它。
  • 創(chuàng)建ManageEmployee.java源文件,如上圖所示,并編譯它。
  • 執(zhí)行ManageEmployee二進(jìn)制文件來運(yùn)行程序。

會(huì)在屏幕上獲得以下結(jié)果,并同時(shí)記錄會(huì)在員工和證書表被創(chuàng)建??梢钥吹阶C書已排序順序相反。可以通過改變映射文件試試,只需設(shè)置sort="natural"和執(zhí)行程序,并比較結(jié)果。

$java ManageEmployee
.......VARIOUS LOG MESSAGES WILL DISPLAY HERE........

First Name: Manoj Last Name: Kumar Salary: 4000
Certificate: MCA
Certificate: MBA
Certificate: PMP
First Name: Dilip Last Name: Kumar Salary: 3000
Certificate: BCA
Certificate: BA
First Name: Manoj Last Name: Kumar Salary: 5000
Certificate: MCA
Certificate: MBA
Certificate: PMP

如果檢查員工和證書表,就應(yīng)該記錄下了:

mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 51 | Manoj   | Kumar   |  5000 |
+----+------------+-----------+--------+
1 row in set (0.00 sec)

mysql> select * from CERTIFICATE;
+----+------------------+------+-------------+
| id | certificate_name | idx | employee_id |
+----+------------------+------+-------------+
| 6 | MCA       |  0 |     51 |
| 7 | MBA       |  1 |     51 |
| 8 | PMP       |  2 |     51 |
+----+------------------+------+-------------+
3 rows in set (0.00 sec)

或者,您也可以映射Java數(shù)組,而不是一個(gè)列表。一個(gè)數(shù)組的映射幾乎是相同的前面的例子,除了與不同的元素和屬性名稱(<array>和<array-index>)。然而,原因如前所述,Hibernate應(yīng)用程序很少使用數(shù)組。

Bag映射
Bag是一個(gè)java集合存儲(chǔ)元素?zé)o需關(guān)心順序,但允許列表中的重復(fù)元素。Bag是在列表中的對(duì)象的隨機(jī)分組。

Collection集合被映射在該映射表中的<bag>元件和與java.util.ArrayList中初始化。
下面的示例中RDBMS表和POJO類依然使用上面定義好的。
定義Hibernate映射文件:
讓我們開發(fā)指示Hibernate如何定義的類映射到數(shù)據(jù)庫表的映射文件。<bag>元素將被用來定義所使用的集合規(guī)則。

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
 "-//Hibernate/Hibernate Mapping DTD//EN"
 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping>
  <class name="Employee" table="EMPLOYEE">
   <meta attribute="class-description">
     This class contains the employee detail. 
   </meta>
   <id name="id" type="int" column="id">
     <generator class="native"/>
   </id>
   <bag name="certificates" cascade="all">
     <key column="employee_id"/>
     <one-to-many class="Certificate"/>
   </bag>
   <property name="firstName" column="first_name" type="string"/>
   <property name="lastName" column="last_name" type="string"/>
   <property name="salary" column="salary" type="int"/>
  </class>

  <class name="Certificate" table="CERTIFICATE">
   <meta attribute="class-description">
     This class contains the certificate records. 
   </meta>
   <id name="id" type="int" column="id">
     <generator class="native"/>
   </id>
   <property name="name" column="certificate_name" type="string"/>
  </class>

</hibernate-mapping>

應(yīng)該保存的映射文件中的格式<classname>.hbm.xml。我們保存映射文件Employee.hbm.xml。前面已經(jīng)熟悉了大部分的映射細(xì)節(jié),但讓我們看到了映射文件中的所有元素再次:

映射文檔是具有<hibernate-mapping>為對(duì)應(yīng)于每一個(gè)類包含2個(gè)<class>元素的根元素的XML文檔。

<class>元素被用于定義數(shù)據(jù)庫表從一個(gè)Java類特定的映射。 Java類名指定使用class元素的name屬性和使用表屬性數(shù)據(jù)庫表名指定。

<meta>元素是可選元素,可以用來創(chuàng)建類的描述。

<id>元素映射在類中的唯一ID屬性到數(shù)據(jù)庫表的主鍵。 id元素的name屬性是指屬性的類和column屬性是指在數(shù)據(jù)庫表中的列。 type屬性保存了Hibernate映射類型,這種類型的映射將會(huì)從Java轉(zhuǎn)換為SQL數(shù)據(jù)類型。

id元素內(nèi)的<generator>元素被用來自動(dòng)生成的主鍵值。將生成元素的class屬性設(shè)置為原生讓Hibernate拿起無論是identity,sequence或者h(yuǎn)ilo中的算法來創(chuàng)建主鍵根據(jù)底層數(shù)據(jù)庫的支持能力。

<property>元素用于一個(gè)Java類的屬性映射到數(shù)據(jù)庫表中的列。元素的name屬性是指屬性的類和column屬性是指在數(shù)據(jù)庫表中的列。 type屬性保存了Hibernate映射類型,這種類型的映射將會(huì)從Java轉(zhuǎn)換為SQL數(shù)據(jù)類型。

<bag>元素用于設(shè)置證書和Employee類之間的關(guān)系。我們使用cascade屬性的<bag>高的元素要告訴Hibernate來保存證書的對(duì)象,同時(shí)為Employee對(duì)象。 name屬性被設(shè)置為在父類中的definedCollection變量,在我們的情況下,它是證書。

<key>元素是包含外鍵的父對(duì)象,即在證書表中的列。表EMPLOYEE。

<one-to-many>元素表示一個(gè)Employee對(duì)象涉及到很多證書的對(duì)象,并因此,證書對(duì)象必須有與Employee父類有關(guān)聯(lián)??梢愿鶕?jù)需要使用<one-to-one>,<many-to-one>或<many-to-many>這個(gè)元素。

創(chuàng)建應(yīng)用程序類:
最后,我們將創(chuàng)建應(yīng)用程序類的main()方法來運(yùn)行應(yīng)用程序。我們將使用這個(gè)應(yīng)用程序,以節(jié)省一些員工的記錄連同的證書,然后我們將申請(qǐng)CRUD操作上的記錄。

import java.util.*;
 
import org.hibernate.HibernateException; 
import org.hibernate.Session; 
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class ManageEmployee {
  private static SessionFactory factory; 
  public static void main(String[] args) {
   try{
     factory = new Configuration().configure().buildSessionFactory();
   }catch (Throwable ex) { 
     System.err.println("Failed to create sessionFactory object." + ex);
     throw new ExceptionInInitializerError(ex); 
   }
   ManageEmployee ME = new ManageEmployee();
   /* Let us have a set of certificates for the first employee */
   ArrayList set1 = new ArrayList();
   set1.add(new Certificate("MCA"));
   set1.add(new Certificate("MBA"));
   set1.add(new Certificate("PMP"));
   
   /* Add employee records in the database */
   Integer empID1 = ME.addEmployee("Manoj", "Kumar", 4000, set1);

   /* Another set of certificates for the second employee */
   ArrayList set2 = new ArrayList();
   set2.add(new Certificate("BCA"));
   set2.add(new Certificate("BA"));

   /* Add another employee record in the database */
   Integer empID2 = ME.addEmployee("Dilip", "Kumar", 3000, set2);

   /* List down all the employees */
   ME.listEmployees();

   /* Update employee's salary records */
   ME.updateEmployee(empID1, 5000);

   /* Delete an employee from the database */
   ME.deleteEmployee(empID2);

   /* List down all the employees */
   ME.listEmployees();

  }

  /* Method to add an employee record in the database */
  public Integer addEmployee(String fname, String lname, 
                   int salary, ArrayList cert){
   Session session = factory.openSession();
   Transaction tx = null;
   Integer employeeID = null;
   try{
     tx = session.beginTransaction();
     Employee employee = new Employee(fname, lname, salary);
     employee.setCertificates(cert);
     employeeID = (Integer) session.save(employee); 
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
   return employeeID;
  }

  /* Method to list all the employees detail */
  public void listEmployees( ){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     List employees = session.createQuery("FROM Employee").list(); 
     for (Iterator iterator1 = 
              employees.iterator(); iterator1.hasNext();){
      Employee employee = (Employee) iterator1.next(); 
      System.out.print("First Name: " + employee.getFirstName()); 
      System.out.print(" Last Name: " + employee.getLastName()); 
      System.out.println(" Salary: " + employee.getSalary());
      Collection certificates = employee.getCertificates();
      for (Iterator iterator2 = 
             certificates.iterator(); iterator2.hasNext();){
         Certificate certName = (Certificate) iterator2.next(); 
         System.out.println("Certificate: " + certName.getName()); 
      }
     }
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
  /* Method to update salary for an employee */
  public void updateEmployee(Integer EmployeeID, int salary ){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     Employee employee = 
          (Employee)session.get(Employee.class, EmployeeID); 
     employee.setSalary( salary );
     session.update(employee);
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
  /* Method to delete an employee from the records */
  public void deleteEmployee(Integer EmployeeID){
   Session session = factory.openSession();
   Transaction tx = null;
   try{
     tx = session.beginTransaction();
     Employee employee = 
          (Employee)session.get(Employee.class, EmployeeID); 
     session.delete(employee); 
     tx.commit();
   }catch (HibernateException e) {
     if (tx!=null) tx.rollback();
     e.printStackTrace(); 
   }finally {
     session.close(); 
   }
  }
}

編譯和執(zhí)行:

會(huì)在屏幕上獲得以下結(jié)果,并同時(shí)記錄會(huì)在員工和證書表被創(chuàng)建。可以看到證書已排序順序相反??梢酝ㄟ^改變映射文件試試,只需設(shè)置sort="natural"和執(zhí)行程序,并比較結(jié)果。

$java ManageEmployee
.......VARIOUS LOG MESSAGES WILL DISPLAY HERE........

First Name: Manoj Last Name: Kumar Salary: 4000
Certificate: MCA
Certificate: MBA
Certificate: PMP
First Name: Dilip Last Name: Kumar Salary: 3000
Certificate: BCA
Certificate: BA
First Name: Manoj Last Name: Kumar Salary: 5000
Certificate: MCA
Certificate: MBA
Certificate: PMP

如果檢查員工和證書表,就應(yīng)該記錄下了:

mysql> select * from EMPLOYEE;
+----+------------+-----------+--------+
| id | first_name | last_name | salary |
+----+------------+-----------+--------+
| 53 | Manoj   | Kumar   |  5000 |
+----+------------+-----------+--------+
1 row in set (0.00 sec)

mysql> select * from CERTIFICATE;

+----+------------------+-------------+
| id | certificate_name | employee_id |
+----+------------------+-------------+
| 11 | MCA       |     53 |
| 12 | MBA       |     53 |
| 13 | PMP       |     53 |
+----+------------------+-------------+
3 rows in set (0.00 sec)

相關(guān)文章

  • JAVA 根據(jù)身份證計(jì)算年齡的實(shí)現(xiàn)代碼

    JAVA 根據(jù)身份證計(jì)算年齡的實(shí)現(xiàn)代碼

    這篇文章主要介紹了JAVA 根據(jù)身份證計(jì)算年齡的實(shí)例代碼及java根據(jù)出生日期獲得年齡的方法,代碼簡單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2018-05-05
  • 谷歌二維碼引擎com.google.zxing二維碼生成與解析

    谷歌二維碼引擎com.google.zxing二維碼生成與解析

    這篇文章主要給大家介紹了關(guān)于谷歌二維碼引擎com.google.zxing二維碼生成與解析的相關(guān)資料,zxing是google開源的二維碼生成和解析工具,需要的朋友可以參考下
    2023-07-07
  • jvm信息jmap使用的基本方法教程

    jvm信息jmap使用的基本方法教程

    JDK本身提供了很多方便的JVM性能調(diào)優(yōu)監(jiān)控工具,除了集成式的VisualVM和jConsole外,還有jps、jstack、jmap、jhat、jstat等小巧的工具,下面這篇文章主要給大家介紹了關(guān)于jvm信息jmap使用的基本方法教程,需要的朋友可以參考下
    2018-08-08
  • 詳解Mybatis-plus(MP)中CRUD操作保姆級(jí)筆記

    詳解Mybatis-plus(MP)中CRUD操作保姆級(jí)筆記

    本文主要介紹了Mybatis-plus(MP)中CRUD操作保姆級(jí)筆記,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • java MD5加密實(shí)現(xiàn)代碼

    java MD5加密實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了java MD5加密實(shí)現(xiàn)過程,為大家分享了MD5加密代碼,感興趣的小伙伴們可以參考一下
    2016-08-08
  • Java數(shù)據(jù)結(jié)構(gòu)之散列表詳解

    Java數(shù)據(jù)結(jié)構(gòu)之散列表詳解

    散列表(Hash table,也叫哈希表),是根據(jù)關(guān)鍵碼值(Key value)而直接進(jìn)行訪問的數(shù)據(jù)結(jié)構(gòu)。本文將為大家具體介紹一下散列表的原理及其代碼實(shí)現(xiàn)
    2022-01-01
  • java模擬實(shí)現(xiàn)微信紅包算法

    java模擬實(shí)現(xiàn)微信紅包算法

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)模擬微信紅包算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • 關(guān)于Prometheus + Spring Boot 應(yīng)用監(jiān)控的問題

    關(guān)于Prometheus + Spring Boot 應(yīng)用監(jiān)控的問題

    這篇文章主要介紹了關(guān)于Prometheus + Spring Boot 應(yīng)用監(jiān)控的問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • SpringBoot配置項(xiàng)目訪問路徑URL的根路徑方式

    SpringBoot配置項(xiàng)目訪問路徑URL的根路徑方式

    這篇文章主要介紹了SpringBoot配置項(xiàng)目訪問路徑URL的根路徑方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • SSH框架網(wǎng)上商城項(xiàng)目第3戰(zhàn)之使用EasyUI搭建后臺(tái)頁面框架

    SSH框架網(wǎng)上商城項(xiàng)目第3戰(zhàn)之使用EasyUI搭建后臺(tái)頁面框架

    SSH框架網(wǎng)上商城項(xiàng)目第3戰(zhàn)之使用EasyUI搭建后臺(tái)頁面框架,討論兩種搭建方式:基于frameset和基于easyUI,感興趣的小伙伴們可以參考一下
    2016-05-05

最新評(píng)論