[Pljava-dev] Returning complex complex objects

From: yazuna at gmail(dot)com (Krzysztof)
To:
Subject: [Pljava-dev] Returning complex complex objects
Date: 2010-12-16 13:52:40
Message-ID: AANLkTinMRakduYUS3jN+1ZD1dv5G+TpPPy-bOV7Dxc-y@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hello Johann,
That's really good news, especially if this could be made robust! I will
think of some ORM code (and maybe JPA plugin) that would create or re-use
existing Java classes to be populated by such call.
Thanks!
Krzysztof

Hi Krzysztof,
>
> On Mon, Dec 13, 2010 at 4:45 PM, Krzysztof <yazuna at gmail.com> wrote:
> > Hello Johann,
> > Certainly, the example of functionality is listed below - I was away
> > from any Postgres console at the time of writing and I rather meant
> > passing complex object to plJava, not getting from:
> > <sql>
> > -- nested, complex types handling...
> >
> > create type B as ( b_val float8,b2_val int)
> > create type C as (c1_val float8, c2_val float8);
> >
> > -- create complex, nested type
> > create type complexA as (
> > ? ? ? ?b B,
> > ? ? ? ?c C,
> > ? ? ? ?a_val int)
>
> Given the types above,
>
> public static int complexParam( ResultSet receiver[] )
> throws SQLException
> {
> for ( int i = 0; i < receiver.length; i++ )
> {
> ResultSet b = (ResultSet)receiver[ i ].getObject( 1 );
> double b_val = b.getDouble( 1 );
> int b2_val = b.getInt( 2 );
>
> ResultSet c = (ResultSet)receiver[ i ].getObject( 2 );
> double c1_val = c.getDouble( 1 );
> double c2_val = c.getDouble( 2 );
>
> int a = receiver[ i ].getInt( 3 );
> ;
> }
>
> return 0;
> }
>
> will handle the following select statement.
> > select complexParam(array_agg(((0.1,i)::B,(0.1,10/i)::C,i)::complexA))
> ?from
> > generate_series (1,10) i;
>
> However, you'll get quite a few lines of
> WARNING: TupleDesc reference leak: TupleDesc 124e930 (139827,-1)
> still referenced
>
> Which I'll be working on soon.
>
> If you run into convoluted examples where the the template above
> doesn't get you started just ask again.
>
>
> Johann
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20101216/e068871b/attachment.html>

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Anantha 2010-12-16 17:05:52 [Pljava-dev] Java VM stalls during
Previous Message Johann 'Myrkraverk' Oskarsson 2010-12-15 16:09:01 [Pljava-dev] Java VM stalls during