Com.apache.dc.query.Query belongs to package name Apache-common-sid.jar

Source: Internet
Author: User

Com.apache.dc.query.Query belongs to package name Apache-common-sid.jar

First of all, this class is based on HQL, a lot of methods inside to pass string clzz, at first I really do not know this parameter to pass what, later to see other people's code to know

To fill in Entity.class.getName () Of course this is a string, you can of course directly spell, "Cn.angelshelter.utils.User"

It is not recommended to use a manually-spelled string, because once you misspell it, the check mechanism inside it will find that the class cannot be found, and then

In the report null pointer error, this also only at run time only exposed, hidden very strong, if with User.class.getName () there is no this problem.

Querymapwithoutselect (map<string, object> map, String clzz) finds data based on the condition parameters inside the map.

Assembled HQL Example: from Cn.angelshelter.utils.User t where 1=1 and t.userid= ' value '


(It is well designed here, if there is a field in the map, it will automatically filter out, so it is not easy to make mistakes, but it seems

Not easy to troubleshoot the problem, you may misspell a field, and finally it did not take effect, it did not error, you think it came into effect, because the programmer's

Intuition, just do not error, my program is OK, this potential bug found the task may be given to the tester, hehe, if the tester is also sloppy

, then the bug has been hidden there, at any time there may be an outbreak of the Oh, good dangerous feeling)

Sort (String fieldName, Boolean isasc) ordering
The illegal field names are not filtered here.

Select () just append a select in Hql.

query.update (String clzz) update
Assembled HQL Example: Update Cn.angelshelter.utils.User

query.clzz (String className) produces a query statement for a table
Assembled HQL Example: from Cn.angelshelter.utils.User t

set (map<string, string> param) append "Set xxx=xxx, xxx=xxx" on the basis of existing HQL

Assembled HQL Example: Set userid3= ' value ', userid= ' value '

Querymapfulljoinwher (map<string, object> map, String clzz) is also a conditional query, but it uses a map

Assembled HQL Example: select New Map (t.name as name, t.pwd as PWD, T.userid as UserID) from Cn.angelshelter.utils.User t where 1 = 1 and t.pwd= ' value ' and t.userid= ' value '

Querymapfulljoinwhereforsql (map<string, string> fields, map<string, object> Map, String clzz) First parameter, control field, first parameter, control condition

assembled HQL Example:select T.userid as userid from T_cdnswitchover t where 1=1 and t.userid= ' value '

Fulljoinwhere (String clzz) full query

assembled HQL Example:select New Map (t.name as name, t.pwd as PWD, T.userid as UserID) from Cn.angelshelter.utils.User t where 1=1

Fulljoinwhereforsql (map<string, string> fieldnames, String clzz) first parameter control field

Select T.pwd as PWD, T.userid as UserID from T_cdnswitchover t where 1=1

Where ()

assembled HQL Example:where 1=1

. Leftbracket ()
Append to end of HQL (

rightbracket ();

HQL appended to the end)

and ();
Append and at end of HQL

Count ()
Note that it does not change the hql itself, but rather in the form of a return string, select COUNT (*) ...

TOHQL ()
Back to HQL

or ()

Append or at end of HQL

eq (String fieldName, String value) equals
assembled HQL Example: t.ff= ' DFDF '

Eqnumber (String fieldName, String value) name does not match the actual
assembled HQL Example:t.dfd= ' 55 '

Eqnumber (String fieldName, String value) doesn't work, it's better to just use EQ
assembled HQL Example:t.dfd= ' DFD '

period (period period) set the time interval

New Period ();p eriod.setbegin(new  date ());p eriod.setend (new  date ()); Period.setkeyfield ("userid"); query.period (period);

assembled HQL Example:t.userid>= ' 2016-03-05 22:38:06 ' and t.userid<= ' 2016-03-05 22:38:07 '

Periodforsql (Period Period) feels no different

NE (string fieldName, String value) is not equal to

assembled HQL Example:t.dd<> ' DFD '

lt (string fieldName, String value) is less than
assembled HQL Example:t.fieldname< ' value '

LE (String fieldName, String value) is less than or equal to
assembled HQL Example:t.fieldname<= ' value '

gt (String fieldName, String value) is less than
assembled HQL Example:t.fieldname> ' value '

ge (String fieldName, String value) is greater than or equal to

assembled HQL Example:t.fieldname>= ' value '

Bw (string fieldName, String value) contains

assembled HQL Example:t.fieldname like '%value% '

In (string fieldName, String value) inside
assembled HQL Example: T.fieldname in(' Dfd,ll ')

In (String fieldName, Integer ... values) inside
assembled HQL Example: T.fieldname in(12,56)

In (String fieldName, Long ... values) inside

in (String fieldName, String ... values) It 's inside .

ni (String fieldName, String value) is not inside
assembled HQL Example:t.fieldname not in (' d ')

IsNull (String fieldName) is empty
assembled HQL Example: T.fieldname isnull

isnotnull (String fieldName) is not empty
assembled HQL Example: T.fieldname isnot null

() HQL append "ORDER BY"

forupdate () HQL append "for Update"

Limitone ()
assembled HQL Example:limit 0,1

Limit (int m, int n)
assembled HQL Example:limit M,n

QueryMap (map<string, string> Map, String clzz) don't know if it's a bug
Select from Cn.angelshelter.utils.User t where 1=1 and t.pwde= ' null ' and t.userid= ' null ' value parts are displayed as null

queryForMap (map<string, object> Map, String clzz) to increase the argument condition
assembled HQL Example: andt.userid= ' value '

Deletemapwithoutselect (map<string, object> Map, String clzz) Conditional Delete
Delete from Cn.angelshelter.utils.User t where 1=1 and t.userid= ' value '

Querymapwithoutselect (map<string, object> Map, String clzz)

From Cn.angelshelter.utils.User t where 1=1 and t.userid= ' value '

Finally, found no way to manually set the HQL ...

Finally, one of the most complex methods, but the feeling is not practical value.

Query.queryrelateclass (String clzz, string subclass) Union Table Query

@WsTitle (isrelate=true, rlclass= "cn.angelshelter.utils.Address", rlfieldcode= "id")Private  int ck;

You need to have parameters in user, including whether the field is associated, the associated class, and which property of the associated class.

Select a from cn.angelshelter.utils.Address A, cn.angelshelter.utils.User t where T.ck = a.id

Com.apache.dc.query.Query belongs to package name Apache-common-sid.jar

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.