Read about hibernate tutorial for beginners, The latest news, videos, and discussion topics about hibernate tutorial for beginners from alibabacloud.com
$ -Panax Notoginseng Propertyname= "Hibernate.show_sql">True Property> - Propertyname= "Hibernate.format_sql">True Property> the + introduce an EMP employee to this entity class configuration file A - the MappingResource= "Entity/emp.hbm.xml">Mapping> + session-factory> - hibernate-configuration>Now let's configure our EMP entity class and t_emp mapping relationship, create a new XML file named
Detailed description of inverse usage in Hibernate (or other ORM). The content is taken from the Java web lightweight development interview tutorial, orminverse
This article is an excerpt from the java web lightweight development interview tutorial.
The English meaning of Inverse is reversal. In Hibernate, it is used t
type
oracle type
binary
style= "font-family: ' Times New Roman ';" >byte[]
varbinary ( or blob)
blob
blob
text
style= "font-family: ' Times New Roman ';" >string
clob
text
clob
serializable TD valign= "Top" width= "
style= "font-family: ' Times New Roman ';" >serializable interface arbitrary implementation class
varbinary ( or blo
In the previous 4 articles, I put hibernate in the general configuration, single-sheet operation, one-to-single-bilateral configuration, one-to-many, multi-pair single-sided configuration, many pairs of single-sided configuration and database operations have been told, if some place is wrong or do not understand the place, but also please correct me. I send the address of a few articles again, convenient for everyone to checkFirst,
reason is not found mapping corresponding resources, yes, we need to move the Student.hbm.xml file to the Cfg.xml file to find the place, so I moved to the same directory, so the complete directory of the final project is as follows:Now look at the results of the JUnit test:Print something out of the console:Hibernate:Drop Table if existsStudenthibernate:Create TableSTUDENT (SIDinteger not NULL, NAMEvarchar(255), Number varchar(255),Primary Key(SID)) April -, . 4: -: -Afternoon Org.hibernate.t
reason is not found mapping corresponding resources, yes, we need to move the Student.hbm.xml file to the Cfg.xml file to find the place, so I moved to the same directory, so the complete directory of the final project is as follows:Now look at the results of the JUnit test:Print something out of the console:Hibernate:Drop Table if existsStudenthibernate:Create TableSTUDENT (SIDinteger not NULL, NAMEvarchar(255), Number varchar(255),Primary Key(SID)) April -, . 4: -: -Afternoon Org.hibernate.t
In the previous chapter we learned about Hibernate configuration and the operation of a single table, this chapter describes one-to-one configuration in hibernateHibernate Getting Started Tutorial chapter IIHibernate one-to-one unilateral bilateral configuration, as well as additions and deletionsPre-Knowledge:1. Fetch, you can set fetch = "SELECT" and fetch = "Join"Fetch = "Select" is the query at the time
Session FactorySession session=sessionfactory.opensession ();//Generate a sessionSession.begintransaction ();//Open TransactionStudent S=NewStudent (); S.setstudentid ("001"); S.setstudentname ("Zhang San"); Session.save (s); Session.gettransaction (). commit (); //Commit a transactionSession.close ();//Close SessionSessionfactory.close ();//Close Session Factory }}If the console does not have an error, you can see what hibernate ha
; }}Class Selection ProfileWe can see from the above configuration that many-to-many were split into 2 one-to-many2. Data manipulationHere we give an added operation, the others are the sameInsert data public static void Fun1 () {Session session = Hibernatesessionfactory.getsessionfactory (). Opensession (); Transaction trans = Session.begintransaction (); Student200 stu = new Student200 (); Stu.setname ("Apache"); Course200 c = new Course200 (); C.setname ("Java"); SC sc = new SC (); sc.setco
= session.createCriteria(Node.class);criteria.add(Restrictions.eq("id",6));List list = criteria.list();System.out.println("list = " + list); It's the equivalent of finding out all of them in the criteria.
Not equal to
Sort
Add pagination
grouping aggregations
Not equal toCriteria criteria = session.createCriteria(Node.class);criteria.add(Restrictions.ne("id",1));List list = criteria.list();System.out.println("list = " + list); SortCriteria criteria = session.createCr
"); 8 C1.setcou Rsename ("Math"), 9 Course c2 = new Course (), C2.setcourseid ("C2"), one C2.setcoursename ("Java"); 12 Course C3 = New Course (), C3.setcourseid ("C3"), C3.setcoursename ("C #"), 15//set computer course this Set16 set The result of the implementation is that while the relevant student and course records can be seen in the student and course tables, there are no associated records in the key Description Student Selection association table (students_courses). The reason is
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.