Think it would be easier if I explained what I'm trying to accomplish.
There is the Class with a graph like this
(Parent) (has-a) (has-a)
Inventory -> Location -> geoLocation
after every hour, I need to update a field in the geoLocation persisted
table with information from the Inventory. My first thought was to run the
UPDATE SQL query, merging its results with the geoLocation table. But now I
see that as an Inventory already holds (indirectly) a geoLocation, I could
access and update it using the Inventory parent class, right?
But I'm still confused about what to write inside the
Stripersist.getEntityManager().createQuery(). What kind of SQL should it
holds? HQL's, MySQL's, JPA? Where could I learn more about it? I'm going to
implement some very specific queries, but I dunno where to start looking
for. I'm confused specially by the UPDATEs, since I could find none on the
Stripes Book code. =) How you update the fields, freddy?
BTW, does stripes have some option for specifying scheduled threads?
Besides updating this table from time to time, I will need to generate some
graphics from our data, on a hourly basis, probably.
bye!
Fabio
On Mon, Aug 31, 2009 at 12:54 PM, Fabio Fonseca <[email protected]> wrote:
> Hello All,
>
> After some hours trying to get it to work, I'm asking for help.
>
> What I want to do is to update a database record accordingly to a SELECT
> result from a SQL clause. I've typed this clause in the MySQL's client and
> it works ok. The data row is updated after a return from the SELECT
> statement.
>
> So I tried to use this SELECT/UPDATE clause inside my app code, but I don't
> know what I'm doing wrong. Instead of the persisted COLUMNs from the DB, I'm
> using the name of the classes. But of no avail.
>
> Stripersist.getEntityManager()
> .createQuery("update location INNER JOIN (select
> location.localidade_id, count(*) as n_count from
> "+getEntityClass().getName()+" as inv where inv.status_ocorrencia='DOWN'
> group by localidade_id) as myJoint set location.num_loc_down =
> myJoint.n_count where location.id =
> myJoint.localidade_id").getResultList();
>
>
> the error from the log file is the following:
>
> Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token:
> INNER near line 1, column 17 [update location INNER JOIN select
> location.localidade_id, count(*) as n_count from buzzlabs.model.Inventory as
> inv where inv.status_ocorrencia='DOWN' group bylocalidade_id as myJoint set
> location.num_loc_down = myJoint.n_count where location.id =
> myJoint.localidade_id]
>
>
> thank you very much for your attention!
> Fabio
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users