I have been searching a lot to find a hibernate/projection code(/function) equivalent for Ucase/Lcase function in simple SQL. Does such thing exist actually? Before delaying any further I will explain my situation.
I have two Tables(One to One) - StudentBean and AddressBean. I'm using a simple object(of Studentbean) embedding mechanism inside AddressBean to keep track of their relationship. I'm using the following method inside my AddressBean Manager class to get whole record (joined from 2 tables) from DB.
public List getAllDetails()
{
Criteria c = sessionFactory.getCurrentSession().createCriteria(AddressBean.class);
c.createAlias("studid", "student");
c.setProjection(Projections.projectionList()
.add(Projections.property((String)"student.studid"), "studid")
.add(Projections.property((String)"student.rollno"), "rollno")
.add(Projections.property((String)"student.name"), "name")
.add(Projections.property((String)"student.phone"), "phone")
.add(Projections.property((String)"address"), "address")
.add(Projections.property((String)"place"), "place")
.add(Projections.property((String)"city"), "city"));
c.addOrder(Order.asc("city"));
c.setResultTransformer((ResultTransformer)Transformers.ALIAS_TO_ENTITY_MAP);
return c.list();
}
The returned list is sorted properly based on 'city' column value. Now my requirement is to convert city column values to pure "UPPERCASE",just like we simply convert as "SELECT UCASE(City) AS Customer, City FROM Customers;" in Simple SQL.
Is it possible?
答案 0 :(得分:0)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button data-colors='["#FF8E2B", "#27AE60"]' style="background:#FF8E2B">click</button>
如上所述更改您的实体类的@Column(name = "City")
@ColumnTransformer(read = "UPPER(City)")
private String city;
属性并尝试...