Here by defining three classes, special, classroom, student to do the test, special and classroom is a one-to-many, classroom and student is a one-to-many relationship, here just paste the property code of these three beans:Special class:public class special{ private int id; private String name; Private String type; Private setClassroom class:public class classroom{ private int id; private String name; Private special special; Private setStudent class:public class student
Tags: blank LAN purpose based on add now programming language Hibernate modeSQL: Full-Name Structured Query Language (structured Query Language), a special purpose programming language, is a database query and programming language for accessing data and querying, updating and managing relational database systems , and is also the extension of the database script file.HQL: HQL (Hibernate query Language) queries provide richer and more flexible query ch
HQL First Class:Hibernate query Language:hibernate querying language Grammar:QueryString hql= "from dept";Query query=session.createquery (HQL);//Return list collectionQuery is a list collectionHQL statement Next note detailed, this production simple operation! 1 Public StaticListgetdept () {2ListNewArraylist();3Configuration conf=NULL;4Sessionfactory fa
HQL (Hibernate query Language) is an object-oriented query language that is very similar to SQL. In Hibernate, HQL is the most widely used method of retrieval.Has the following frequently used functions:(1) In the query statement, can set various conditions(2) Support checking out the object part of the property, is not in the SQL statement *, but query the object we want to query(3) Support connection quer
The session is the basis of the persistence layer operation, equivalent to the connection in JDBC, which saves, updates, and finds data through session sessions.Session is the center of Hibernate operation, object life cycle, transaction management, database access are related to the sessionSession created by Sessionfactory is a thread-safe thread-safe that allows multiple threads to access sessionfactory at the same timeand there's no data sharing problem.Explanation of Session in Hibernate: ht
/** * Paging query/Public List pagequery (Userinfo Userinfo) {String hql= ' select u from Userinfo u where 1=1 '; final List Paraml ist = new ArrayList (); if (Userinfo.getuserid ()!=null) {hql+= "and u.userid>?"; Paramlist.add (Userinfo.getuserid ()); } if (Userinfo.getusername ()!=null! "". Equals (Userinfo.getusername (). Trim ())) {hql+= "and username like?";
a strong help: first, in-depth understanding of users and use of the environment, to find the target users, to find their environment and potential behavior; second, the real comprehensive data analysis and support; again, Quweicunzhen, think one more step, you know. , competitors know that you only need a little more than they know, grasp the inspiration to embody creativity, reasonable choice, like in Noah's Ark to throw away all the burden of things, and finally the courage to do the product
When writing the HQL statement, if you use a custom function, HQL will not compile through the compilation process, we need to rewrite the next dialect dialect class, where my Oracle is 10, can inherit different Oracle dialect classes according to their Oracle version.Steps to resolve the error:First, rewrite the dialect class, such as Oracle10gdialectSecond, modify hibernate configuration file, the default
Parameter bindings for Hibernate HQL queries (2010-07-15 09:20:16)reproduced
Tags: gossip
Category: JAVA
parameter bindings: Hibernatein the dynamic query parameter binding provides rich support, then what is the query parameter dynamic binding? In fact, if we're familiar with traditionJDBCprogramming, we are not difficult to understand the query parameters dynamic binding, the following code traditionJDBCparameter
Weblogic8.1 + hibernate3.0: the following error occurs when Weblogic is started: charscanner; panic: classnotfoundexception: org. hibernate. hql. Ast. hqltoken. Then the server crashes directly.
Solution: Add a property hibernate. query. factory_class to hibernate. hql. Classic. classicquerytranslatorfactory in hibernate. properties or conext XML of spring. The value is org. hibernate.
Select clauseUsed to select a specified attribute or directly select an object. Of course, the select attribute must be an attribute contained in the from persistence class. For example:
select p.name from Person as p
Select can select any attribute, that is, not only the direct attribute of the persistence class can be selected, but also the attribute contained in the component property, such:
select p.name.firstname from Person as p
NormallyResult is setThe Set element is an array composed of
Hql queries some fields in a single table:
In hibernate, the object class is queried using hql statements, and the returned result of the list method is a list. The objects encapsulated in the list are divided into the following three situations:
1. When you query all fields, such as "from object class", the objects encapsulated in the list are the object class, And all attributes are filled.
2. query on
After the project is moved from TOMCAT7 to WEBLOGIC12C, the exception org. hibernate. QueryException: ClassNotFoundException occurs:
Org. hibernate. hql. ast. HqlToken;
I checked on the Internet, because hibernate3.0 is based on anlr HQL/SQL query translator, using antlr-x-x-x.jar, however weblogic. jar already contains the antrl class library, and weblogic. the jar loading sequence is limited than the jar
HQL query:1. For the HQL query statement in the form of greetings, if more than one question mark, which is more troublesome to the following parameters.such as: From Student Student where student.name =? and student.age=?....For such assignments, error-proneAnother way of assigning a value can be usedsuch as: From Student Student where Student.name =:var1 and student.age=:var2 ....Query.setstring ("Var1",
String str = "Chinese string";String hql = "from Table as T WHERE t.field like '%" + str + "%";Query query = getsession (). CreateQuery (HQL);Query.list ();Using this form to pass in parameter str results in console output:From Table as T WHERE t.field like '%???? %'such as garbled, so that the database can not find matching records.It is said that this is a problem with the hibernate3.0 like clause dealing
String str = "Chinese string";String hql = "from Table as T WHERE t.field like '%" + str + "% '";Query query = getsession (). CreateQuery (HQL);Query.list ();Using this form to pass in the parameter str causes the console output:From Table as T WHERE t.field like '%???? %'To find a matching record in the database.It is said that this is an issue with the hibernate3.0 like clause dealing with Chinese, 3.1 ha
This essay will document HQL's frequently used query statements to facilitate future viewing.Here by defining three classes, special, classroom, student to do the test, special and classroom is a one-to-many, classroom and student is a one-to-many relationship, here just paste the property code of these three beans:Special class:public class special{ private int id; private String name; Private String type; Private setClassroom class:public class classroom{ private int id; priv
Hibernate is equipped with a very powerful Query Language, which looks like SQL. But do not be confused by syntax-structure similarity. hql is consciously designed as a fully Object-Oriented Query That can understand concepts such as inheritance, polymorphism, and association.1. Case sensitivity
Except for the names of Java classes and attributes, query statements are not case sensitive. SoSelectAndSelectAndSelectIs the same,Org. hibernate. eg. fooNot
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.