Sort DetachedCriteria mysql English

分类:Java 2009-11-29 来源:CodeWeblog.com 人气:205

The detachedCriteria using hibernate query, the need for string sorting, according to hibernate sort provided is not very cool to realize sort according to Pinyin, the database to use mysql.

MysqlOrder. Java wrote

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.CriteriaQuery;
import org.hibernate.criterion.Order;

public class MysqlOrder extends Order (
private String propertyName;

protected MysqlOrder (String propertyName) (
super (propertyName, false);
this.propertyName = propertyName;
)

/ **
* Only consider the situation sorted by a field
* /
public String toSqlString (Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException (
String [] columns = criteriaQuery.getColumnsUsingProjection (criteria, propertyName);
return "CONVERT (" + columns [0] + "USING GBK)";
)

public static MysqlOrder getOrder (String propertyName)
(
return new MysqlOrder (propertyName);
)
)

本文关键词: public string import org criterion
分享到:
blog comments powered by Disqus

相关文章

  • Dynamic programming largest public String 2010-11-16

    Dynamic programming ----- seeking maximum public string two strings package zju; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SameString { public static void main(String[] args){ String s1=

  • Public String substring with maximum similarity String Process (2) 2010-04-06

    Most common sub-string: 2009-11-27 10:421. Levenshtein Distance The algorithm is also known as "edit distance", used to calculate the similarity of two strings. The principle is very simple, it is returned to the first string (delete, inser ...

  • java string concatenation 2010-03-29

    Note: Reference http://www.blogjava.net/nokiaguy/archive/2008/05/07/198990.html The string is a Java program, the most commonly used one of a data structure. In Java, the String class has overloaded the "+." In other words, the string can u ...

  • Object is converted to JSON string 2010-03-29

    Keywords: json package com.sy.test; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; / ** * Providing the object is converted to JSON string method * @ Author author Li Youth * @ Version Version 0.01 * @ Filename ...

  • java string encoding conversion 2010-03-29

    java string encoding conversion, whether the program localization is international, will involve the conversion of character encoding issues. Especially in web applications often need to deal with Chinese characters, when a string is needed, encoding ...

  • Spring through inheritance PropertyEditorSupport convert a string to a specific type of treatment 2010-03-29

    Example: 1, write POJO class Car.java: package com.xfc.test.propertyedit; public class Car ( private int horsepower; private String color; public int getHorsepower () ( return horsepower; ) public void setHorsepower (int horsepower) ( this.horsepower ...

  • (Turn) java string convert a variety of encoding 2009-03-05

    To build public java class ChangeCharset.java java's String class is conducted in accordance with unicode encoding, when using the String (byte [] bytes, String encoding) constructor string, encoding refers to the bytes of the data is encoded in ...

  • Revised json string generated java class 2010-01-04

    Reprinted: http://www.gold98.net/blog/article.asp?id=676 Remember wrote a json string on the generated java class, because the use is relatively small, so it does not go into details about the recent study and EXT, in its use has also highlighted jso ...

  • gson (JSON string into an equivalent Java object) 2010-03-19

    Most of the gson also requires the use of java class in the use of java annotation, do not fully support POJO. Gson This Java class library can be converted into Java objects JSON, the JSON string can be converted into an equivalent Java object. Gson to s

  • Project page type used in public 2010-03-29

    Help 1. In the corresponding action code you add the four properties, generating a corresponding set get method. private PageModule pm; / / paging model class private int page = 1; / / initialize the page private PageManager pma; / / page management class

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.063 (s). 14 q(s)