openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: SchemaGenerator and connections
Date Mon, 05 Apr 2010 21:21:29 GMT
I'd have to look at the code paths involved, but in the 'mainline' code we
wrap the real connection in a RefCountConnection. RefCountConnection
maintains a count of the number of times it's been handed out decrementing
it when ever it's closed. The real connection won't be closed until the
counter reaches 0.

If we create the same wrapper in the SchemaGenerator then you should be able
to get the connection in the main method (incrementing the count) and then
close it at the end.

If everything's working right the individual methods will get the same
connection - the count won't drop to 0 until the end of the main method and
you should be okay.

Something along those lines should be feasible, and with some luck you won't
have to change any signatures along the way.

Best Regards,
-mike

On Mon, Apr 5, 2010 at 4:06 PM, Daniel Toffetti <dtoffe@yahoo.com.ar> wrote:

>
>    Sure I can, the problem is that I tried the quickest approach that came
> to mind just to see if it worked, and that means receiving a Connection in
> the constructor and keeping a local reference to it.
>    I'm mostly sure such a thing will probably be frowned upon since it can
> lead to leaks and/or unproperly managed resources. The current code
> properly
> obtains a Connection in every method body's beggining and releases it at
> the
> end. But since I get the connection from outside, I can't close it and
> create it again later.
>    I'll try to come up with a better solution and provide a patch.
>
> Thanks for your help !
>
> Daniel
>
>
> Rick Curtis wrote:
> >
> >
> > I haven't really looked at the SchemaGenerator before, but what all did
> > you
> > change? Perhaps you can post a patch with your changes?
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/SchemaGenerator-and-connections-tp4852136p4855448.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message