PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

ResultTransformer con createSQLQuery non forza camelCase nei campi entità

Puoi usare addScalar(String columnAlias, Type type) per dichiarare esplicitamente l'alias di colonna del tuo SQL nativo:

  getCurrentSession()
  .createSQLQuery( "select e.id as id,e.first_name as firstName,e.password as password from xxxxxx")
                .addScalar("id",StandardBasicTypes.INTEGER )
                .addScalar("firstName",StandardBasicTypes.STRING )
                .addScalar("password",StandardBasicTypes.STRING )
                .setResultTransformer(Transformers.aliasToBean(Employee.class))
                .list();