[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Can save but not retrieve using
From:       dave.potts () pinan ! co ! uk
Date:       2010-08-27 7:26:19
Message-ID: 51167.153.98.68.197.1282893979.squirrel () dp2642 ! force9 ! co ! uk
[Download RAW message or body]

Hi

Have you checked in the postgres database logs?

There might be a clue in there as to why it is not working

> El Thursday 26 August 2010, Paulo Angelo escribió:
>> Hi Ppl,
>>
>>   I'm getting a weird problem. I can save a Geometry type through
>> Hibernate
>> but I can't retrieve it.
>>
>>  WKTReader fromText = new WKTReader();
>>  Geometry geom = fromText.read("POLYGON((0 0,0 3,3 3,3 0,0 0))");
>> Session session = dao.newSession();
>> Transaction tx =  dao.beginTransaction(session);
>> Query q = session.createQuery("select f from Geometries f");
>> List list = q.list();
>> Poligono to = (Poligono) lista.get(0);
>> dao.commitTransaction(session, tx);
>> to.setPoli(geom);
>> System.out.println(to.getPoli().toString());  // Apears "POLYGON ((0 0,
>> 0
>> 3, 3 3, 3 0, 0 0))"
>> dao.alterar(to, null, null);
>>  // I can see via SQL that it saves correctly
>
> And have you checked that it appears in the database after the commit?
> Maybe
> the commit is not really commited (can't see why, though).
>
>> // Now, retrieve
>> session = dao.newSession();
>> tx =  dao.beginTransaction(session);
>> q = session.createQuery("select f from Geometries f");
>> list = q.list();
>> to = (Poligono) lista.get(0);
>> dao.commitTransaction(session, tx);
>> System.out.println(to.getPoli().toString());
>>  // Get a *NullPointerException*, because to.getPoli() is null
>>
>
> Have you tried debugging step by step checking that all variables are ok?
> Are
> you sure that "to" is not null instead of to.getPoli()?
>
> Have you tried using Criteria instead of hql? Maybe it is a conversion
> problem
> between geometry types.
>
> Could it be that closing/commiting the transaction is the problem? If
> hibernate didn't get all the data on one shot, closing the transaction
> makes
> hibernate unable to get more info from the database.
>
> Anyway, if you rollback a read-only transaction instead committing,
> hibernate
> goes faster.
>
>
> --
> María Arias de Reyna Domínguez
> Área de Operaciones
>
> Emergya Consultoría
> Tfno: +34 954 51 75 77 / +34 607 43 74 27
> Fax: +34 954 51 64 73
> www.emergya.es
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>


-- 
Any views expressed in this message are those of the individual sender,
except where the sender specifically states them to be the views of the
Pinan Software


_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic