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.