Sort DetachedCriteria mysql English

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);

分类:Java 时间:2009-11-29 人气:228
本文关键词: 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; import; import; 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, insert, re

  • java string concatenation 2010-03-29

    Note: Reference 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 use th

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

    Keywords: json package; 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 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 import; /** * Converts a string encoding */ public class ChangeCharset { /** 7 ASCII characters , Also called ISO646-US.Unicode the Basic Latin block character set */

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

    Reprinted: 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

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

    package; import org.hibernate.Query; import; public class PageManagerimple extends HibernateDaoSupport implements PageManager{ private PageModule pm = new PageModule(); pub

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.190 (s). 13 q(s)