How translate this code from sql to Hibernate?

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 Tabla_Datos(){ Session s = HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction(); List lista = (List)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 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 to`coordenadas` 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;

以上就是How translate this code from sql to Hibernate?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏