Detailed notes on Hibernate and hibernate

Source: Internet
Author: User

Detailed notes on Hibernate and hibernate

Add environment in the Hibernate configuration file. 1. jar package 2. configuration File hibernate. cfg. xml/xxx. hbm. xml3. use hibernate to add, delete, modify, and query Configuration cfg = new configuration. config (); SessionFactory sessionFactory = cfg. buildSessionFactory (); Session session = sessionFactory. openSession (); Try {Transaction tx = session. beginTransaction (). commit ();} catch (Exception e) {Tx. rollback ();} finally {Session. close ();} 4. method: save (object)/update (object)/delete (Object)/c ReateQuery (hql ). /get (class, id) 5. main configuration file: database information: dialect, URL, driver, user name, password import ing file other configurations show_ SQL = true; hbm2ddl. auto = update; 6. ing configuration ing basics: constructor without parameters. get and set Methods map common attributes such as name, type, length, column, not-null to the primary key native, assigned, uuid, hilo and so on 1 hibernate. cfg. xml this file is configured with the url of the database required by Hibernate and the account and password information such as: <! DOCTYPE hibernate-configuration PUBLIC "-// Hibernate/Hibernate Configuration DTD 3.0 // EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <! -- Generated by MyEclipse Hibernate Tools. --> 

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.