I need help with this code from sql to Hibernate, please I hope you help me with this work...
SELECT x(coordenadas) as latitud, y(coordenadas) as longitud FROM datos;
I'm a new user in this page :-(
I have two tables called datos and dispositivo, I'm using hibernate from Netbeans for get registers of the table called datos, but the problem is that I dont know how convert this sentence. because my table contains a register with a type data "geometry properties functions" called "coordenadas". GeomFromText("Point(18.30 -99)"). I need get the register of this table as Latitud and Longitud in a list. Help me please :(. I sorry for my English, I'm learning.
I had a table with these registers datos,fecha,dirLat,dirLong,Latitud,Longitud,altura and I take the registers with this method...
package Modelo;
import com.conf.hibernate.HibernateUtil;
import com.hibernate.Datos;
import java.util.List;
import org.hibernate.Session;
public class FuncionesHibernate {
public List<Datos> Tabla_Datos(){
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
s.beginTransaction();
List<Datos> lista = (List<Datos>)s.createQuery("From Datos").list();
s.getTransaction().commit();
return lista;
}
}
then with this code from a Servlet, I got Latitud and Longitud...
FuncionesHibernate funcionesHibernate = new FuncionesHibernate();
List<Datos> lista = funcionesHibernate.Tabla_Datos();
for(Datos d : lista){
latitud=d.getLatitud();
longitud=d.getLongitud();
}
The problem is that the tables was updated, and the registers that contained Latitud and Longitud changed tocoordenadas
geometry. Well now I need insert registers for this new way in the console for mySql.
insert into datos values(1,1,"2013-02-02","14:00:00",GeomFromText("Point(18.30 -99)"),20);
and now my method called 'FuncionesHibernate ' can't working.
There isn't another way for 'coordenadas' registers get with the new table? What's the new query for Hibernate??
for this razon I need translate this query to query for Hibernate..
SELECT x(coordenadas) as latitud, y(coordenadas) as longitud FROM datos;