openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ignacio Andreu" <plunch...@gmail.com>
Subject Re: How to get I get to the read JDBC Connection object...
Date Fri, 04 Apr 2008 20:06:56 GMT
I review the conversation If you're using PostgreSQL, the actual InputStream
/ Reader don't have support for PostgreSQL, although if you've a good
solution for Large Object in PostgreSQL please e-mail me.


- Ignacio

On Fri, Apr 4, 2008 at 7:16 PM, Ignacio Andreu <plunchete@gmail.com> wrote:

> Hi,
>
> The InputStream / reader support is not documented yet, I want to provide
> some documentation soon.
>
>
> BTW I sent a patch for the InputStream / Reader support a week ago, this
> patch solves some bugs, Can you review and commit the patch? Thanks in
> advance!!
>
>
>
>
> On Fri, Apr 4, 2008 at 5:32 PM, Patrick Linskey <plinskey@gmail.com>
> wrote:
>
> > >  > Additionally, note that OpenJPA 1.1.0-SNAPSHOT has support for
> > fields
> > >  > of type InputStream; with this support, OpenJPA will never fully
> > load
> > >  > the data into memory.
> > >  I can see how this will work for readonly values, how about write
> > ones?
> > >  Also looking in the 1.1.0 manual I can not find any reference to
> > InputStream.
> >
> > I think it hasn't been documented yet. Take a look at
> > InputStreamLobTest for an example.
> >
> > For write values, you simply assign the InputStream field to the
> > stream that OpenJPA should read from when streaming to the database:
> >
> >    @Entity
> >    public class Picture {
> >        @Persistent private InputStream data;
> >
> >        public void streamContentsIntoDatabase(InputStream is) {
> >            data = is;
> >        }
> >
> >        public InputStream streamContentsFromDatabase() {
> >            return is;
> >        }
> >    }
> >
> > -Patrick
> >
> > On Fri, Apr 4, 2008 at 6:57 AM, David Goodenough
> > <david.goodenough@btconnect.com> wrote:
> > > On Tuesday 01 April 2008, Patrick Linskey wrote:
> > >  > Or, even more simply:
> > >  >
> > >  > em.getTransaction().begin();
> > >  > Connection c = OpenJPAPersistence.cast(em).getConnection();
> > >  Actually for what I need I need to cast this to a
> > DelegatingConnection
> > >  and then get the PGConnection by casting its InnermostDelegate.
> > >  But yes, this works - thank you.
> > >
> > > > try {
> > >  >     ...
> > >  > } finally {
> > >  >     c.close(); // the connection is a wrapper; this decrements the
> > >  > reference count
> > >  > }
> > >  > em.getTransaction().commit();
> > >  >
> > >  > Additionally, note that OpenJPA 1.1.0-SNAPSHOT has support for
> > fields
> > >  > of type InputStream; with this support, OpenJPA will never fully
> > load
> > >  > the data into memory.
> > >  I can see how this will work for readonly values, how about write
> > ones?
> > >  Also looking in the 1.1.0 manual I can not find any reference to
> > InputStream.
> > >
> > >  David
> > >
> > >
> > > >
> > >  > -Patrick
> > >  >
> > >  > On Mon, Mar 31, 2008 at 8:31 PM, Pinaki Poddar <ppoddar@apache.org>
> > wrote:
> > >  > >  Hi,
> > >  > >    Following should work:
> > >  > >
> > >  > >
> > >  > >
> > >  > >  import javax.persistence.EntityManager;
> > >  > >  import org.apache.openjpa.kernel.Broker;
> > >  > >  import org.apache.openjpa.jdbc.kernel.JDBCStore;
> > >  > >  import org.apache.openjpa.persistence.JPAFacadeHelper;
> > >  > >  import java.sql.Connection;
> > >  > >
> > >  > >         EntityManager em = emf.createEntityManager();
> > >  > >         Broker broker = JPAFacadeHelper.toBroker(em);
> > >  > >
> > >  > >         JDBCStore store = (JDBCStore)broker.getStoreManager();
> > >  > >         Connection con = store.getConnection();
> > >  > >
> > >  > >  David Goodenough-3 wrote:
> > >  > >  > I need to get to the real JDBC Connection object so that I
can
> > do some
> > >  > >  > processing using Postgresql extensions (in particular the
> > LargeObject
> > >  > >  > support).  I do not expect OpenJPA to understand what I am
> > doing, but
> > >  > >  > I need to access the Connection object and I need what I do
to
> > be
> > >  > >  > in the same transaction as that used by OpenJPA (so also it
> > needs to
> > >  > >  > be the same transaction).
> > >  > >  >
> > >  > >  > The manual suggests:-
> > >  > >  >
> > >  > >  > OpenJPAEntityManagerFactory kemf =
> > OpenJPAPersistence.cast(emf);
> > >  > >  > OpenJPAConfiguration conf = kemf.getConfiguration();
> > >  > >  >
> > >  > >  > on page 190, but kemf does not have a getConfiguration method
> > >  > >  > according to Eclipse (using OpenJPA 1.0.2).
> > >  > >  >
> > >  > >  > The OpenJPAConfiguration javadoc is not much use either in
> > that it
> > >  > >  > does tell me where to get it from.
> > >  > >  >
> > >  > >  > Any ideas?
> > >  > >  >
> > >  > >  > David
> > >  > >
> > >  > >  --
> > >  > >  View this message in context:
> > >  > >
> > http://www.nabble.com/How-to-get-I-get-to-the-read-JDBC-Connection-object
> > >  > >...-tp16400383p16401689.html Sent from the OpenJPA Users mailing
> > list
> > >  > > archive at Nabble.com.
> > >
> > >
> > >
> >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>
>

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