mercredi 25 mars 2015

Cannot Seem to retrieve data from table in the order of the database table's column order

I want to to retrieve data from table in the order of the database table's column order.


Suppose my sql query is



String sql_string = "select * "
+ "from CUSTOMER_INFO "
+ "order by customer_last_name, customer_first_name";

Session session = factory.openSession();
Transaction tx = session.beginTransaction();
List<Map<String,Object>> results = session.createSQLQuery(sql_string)
.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE)
.list();


In database, the table's column order is like A,B,C,D. But when I retrieve the data and iterate through it, the entrySet is like C,A,D,B. (int,float,float,String)


I think the data is being retrieved based on its datatype.


I need the retrieved entrySet in the same order as it exists in database's table.


I also tried specifying the column names in select query which was of no use.


CUSTOMER_INFO is model class mapped to sqllite through hibernate.



@Entity
@Table(name = "CUSTOMER_INFO")
public class CustomerInfo{
@Column
private int C;
@Column
private float A;
@Column
private String B;
@Column
private float D;

//getters and setters
}


Using Sqllite 3.6, hibernate, JSP.


Any help is appreciated.


Aucun commentaire:

Enregistrer un commentaire