Introduction: Why this demand, from the company's project needs, the company's projects using Java struts2+spring2.5+oracle Middleware tuxedo, database with Oracle, but because not directly connected to the database, with the middleware processing way, And do not want to have too much service, so began to network to find data collation coding. It took about one weeks to complete the task, and now it's all sorted out to share with you. 1. need to impo
inherited, so that the user can change the tool class things. So generally we will use Finalkeyword.Package Cn.itcast.hibernate;import Org.hibernate.session;import Org.hibernate.sessionfactory;import Org.hibernate.transaction;import Org.hibernate.cfg.configuration;public Final class Hibernateutil {private static Sessionfactory sessionfactory;private Hibernateutil () {}static{configuration cfg = new Configuration (); Cfg.configure ( ); sessionfactory = Cfg.buildsessionfactory ();} public static
First, let's take a look at the diagram below, explaining a request flow for a Web application!Description of lazy Load exception:Lazy loading is when we query an object, all of its properties are to be detected!If lazy loading is turned on, the session is closed on the service layer, and if our view does not need his attributes, then there will be no lazy loading exception, if the need for attributes, this time the session is closed so there will be lazy loading exception, At this point we will
table of the department can be empty, until the fresh, formally become a department, it is not empty. Also indicates that the foreign key can be empty at ordinary time)**********5The query form of the associated data (retrieval policy) ****************************************************loading of associated data in 3 scenarios1Delay (lazy) is also called lazy loading: Session.close () is called immediately after the class data is found; the default is lazy (lazy) loading. That is, the statemen
(restrictions.lt ("age", 30));C.add (restrictions.ge ("age", 30));• Search for students younger than 35 years old with "swords" in their professional skillsC.add (Restrictions.and ("Age", "restrictions.lt"), Restrictions.like ("skill", "% sword%"));qbc--Multi-Table Association queryL Query Teachers "All students of Li Joliang"? Unable to find the Teacher.teachername propertyL use aliases to refer to Teacher.teachername object graph navigation? Use the alias T to represent the associated propert
Build a table can be reversed with myeclipse to generate the class can also generate mapping files (more convenient)First-class can set Hibernate property dynamically generated table but the mapping file to choose their ownWhen doing a project, the data is analyzed first, and a data dictionary is formed. When the data dictionary comes out, we can build the table from the data dictionary to write the SQL statement, or we can write the entity class or e
data that is exactly the same (note that the ID has changed, but that's not changed), so how to correspond to the ID in Idcard. Therefore, it is not advisable to use this method in practical applications.Second: The ID in person is treated as the primary key as a foreign key. The mapping relationship is as follows:The main is to modify the Person.hbm.xml file. At this point, when you delete the Idcard table, a prompt pops up:Tip We cannot delete, there are foreign key constraints.Summary: A s
1. New a Web project.2. Right-click the project to add struts support for the project.Click Finish. The SRC directory has more struts.xml configuration files.3, use MyEclipse Database Explorer to establish a data source. new a data source. Fill in the data source information. Click Test Driver, if successful display: Click OK, click Finish. 4, add spring support for the project. The selects five packages, after which the jar Library installation as. Click Next. Click Finish by default. 5, a
individual fields are queried, the returned list contains object[]
listlist
Querying a single Entire object: Using the "from sampletable t where T.field =: Filed" notation, default returns the Encapsulated Sampletable object list
Querying multiple Entire objects: You can specify which objects to get, such as "select T1, t2 from sampletable T1, sampletable T2 where ...", which returns a list containing object[],object[] In 0-bit Sampletable object, 1 is Sampletable objec
property and the description, parent property of the Department of the Development Department, and not change the original "Children" attribute, then we will use the following method to update instead of directly. First, find the persisted object in the database by using the ID of the "development department" passed by the page table only son, and then assign the value by the set () method to the Name,description,parent property of the persisted object; Using the Session.update () method to upd
One, hql query (Hibernate query Language) Multi-table query, but not complex when usedHibernate exclusive Query Language, which belongs to object-oriented query language1. Basic Inquiry2. Conditional queryNote: There is no database-related information in the HQL statement1)? Placeholder2) named placeholders3, paging queryIi. Criteria Query (single-table conditional query)Hibernate self-created non-statement
The Hibernate data model is used to encapsulate data, and development requires compliance with the following specifications:1) provides a common, non-parametric construction method (can be used automatically generated)If you use projection technology, be sure to explicitly declare a public parameterless construction method2) Provide an identity property as the primary key for the object, and map the database table primary keyThe UUID is usually used a
Integration of the SSH framework (struts-2.5.5+spring-4.3.4+hibernate-5.2.4) 1.jdk-1.8 TOMCAT7 Environment 2. Create a Web Project 3. Guide Package (Struts+spring+hibernate) 4. Create Struts.xml and Spring.xml (applicationcontext.xml) struts.xml header in SRC to add several common properties (not added)
Some Web applications use struts's Tiles Layout Framework to open design pages. I don't think the pages are simpler. There are too many configuration files and template pages, which is confusing, but I should record them, in case you use it one day...
The web. xml of the program is written in this way.
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"Xsi: schemaLocation = "http://java.sun.com/xml/ns/j2eeHttp://java.sun.com/xml/ns/j2ee/web-app_2
First, the collection cache1. Do not use the collection cache:2. Use the collection cache:1) Configuration Hibernate.cfg.xml2) Test:
Second, supplemental level two cache, collection cache configuration
Third, query cacheList () is only cached by default and will not be taken from the first-level cache.Using the query cache, you can have the list () query take from the level two cache.1, Configuration Hibernate.cfg.xml2. Test class
Iv. management of the session in the project1, Configuration H
three states of Hibernate.Transient status (Transient)Just created with the new statement, it has not been persisted and is not in the Session cache.Persistent)Already persisted and added to the Session cacheDetached)It has been persisted but is no longer in the Session cache
III persistence and ORM are also part of what Hibernate needs to understand.Persistence: Data Model (memory) "--" Storage Model (persistence device). Persistence in
In the JAVA interview, I asked about the comparison between HIBERNATE and MYBATIS. Here I will make a summary. hibernatemybatis
I am a java developer, I have studied hibernate and mybatis. I was mentioned during the java interview and applied it in project practice. Now I wa
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.