pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedPGXADataSource does not implement DataSource
6+ messages / 3 participants
[nested] [flat]
* PGXADataSource does not implement DataSource
@ 2007-04-20 20:00 Bill Middleton <utvikler@gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Bill Middleton @ 2007-04-20 20:00 UTC (permalink / raw)
To: pgsql-jdbc
Hello and thanks for for the efforts. I've noticed that your XA
implementation does not formally implement javax.sql.DataSource. I felt
pretty sure that this was a simple oversight, given that BaseDataSource
provides complete compatibility with the DataSource interface. I patched
thusly:
Index: org/postgresql/ds/common/BaseDataSource.java
===================================================================
RCS file:
/usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/ds/common/BaseDataSource.java,v
retrieving revision 1.7
diff -r1.7 BaseDataSource.java
12a13,14
> import javax.sql.DataSource;
>
25c27
< public abstract class BaseDataSource implements Referenceable
---
> public abstract class BaseDataSource implements Referenceable, DataSource
and now Hibernate happily accepts the postgresql XA using JTA.
Best regards,
Bill Middleton
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PGXADataSource does not implement DataSource
@ 2007-04-20 20:26 Kris Jurka <books@ejurka.com>
parent: Bill Middleton <utvikler@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Kris Jurka @ 2007-04-20 20:26 UTC (permalink / raw)
To: Bill Middleton <utvikler@gmail.com>; +Cc: pgsql-jdbc
On Fri, 20 Apr 2007, Bill Middleton wrote:
> Hello and thanks for for the efforts. I've noticed that your XA
> implementation does not formally implement javax.sql.DataSource. I felt
> pretty sure that this was a simple oversight, given that BaseDataSource
> provides complete compatibility with the DataSource interface. I patched
> thusly:
>
The javadoc doesn't have XADataSource extending Datasource so we didn't
either.
> and now Hibernate happily accepts the postgresql XA using JTA.
>
Are you sure this works completely? How is Hiberate able to access any
XA things if it's only using a regular Datasource/Connection?
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PGXADataSource does not implement DataSource
@ 2007-04-20 20:32 Heikki Linnakangas <heikki@enterprisedb.com>
parent: Bill Middleton <utvikler@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2007-04-20 20:32 UTC (permalink / raw)
To: Bill Middleton <utvikler@gmail.com>; +Cc: pgsql-jdbc
Bill Middleton wrote:
> Hello and thanks for for the efforts. I've noticed that your XA
> implementation does not formally implement javax.sql.DataSource. I felt
> pretty sure that this was a simple oversight, given that BaseDataSource
> provides complete compatibility with the DataSource interface. I patched
> thusly:
I'm not sure that's a smart a smart thing to do. I don't think there's a
requirement for XADataSource implementations to implement DataSource as
well. If that was the case, surely XADataSource interface would inherit
DataSource to enforce that. If we declare that PGXADataSource implements
DataSource, then one can erroneously configure the container to use
PGXADataSource in normal DataSource-mode. In fact I suspect that's the
case in your environment as well.
Can you provide a simple test case involving Hibernate so that I can try
this out myself? What's in your hibernate config file?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PGXADataSource does not implement DataSource
@ 2007-04-20 20:56 Bill Middleton <utvikler@gmail.com>
parent: Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Bill Middleton @ 2007-04-20 20:56 UTC (permalink / raw)
To: Heikki Linnakangas <heikki@enterprisedb.com>; books@ejurka.com; +Cc: pgsql-jdbc
Hello again, and thanks for the feedback. Yes, I'm likely in way over my
head here. However, things are working acceptably with minimal testing so
far. I register my modified PGXA as the resource in a
UserTransactionService and then pass it into hibernate via jndi lookup,
along with a transactionmanager. The interesting bits of
hibernate.cfg.xmlare then:
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.datasource
">java:comp:myDS</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory</property>
Hibernate accesses the DS in
org.hibernate.connection.DataSourceConnectionProvider
I'm using the atomikos TM, and sharing the DS between hibernate and a (also
slightly modified) up jboss cache.
Note that this works fine with Derby's embedded XA datasource, and they do
implement DataSource, but again, I'm a novice at all this.
Any further advice appreciated.
On 4/20/07, Heikki Linnakangas <heikki@enterprisedb.com> wrote:
>
> Bill Middleton wrote:
> > Hello and thanks for for the efforts. I've noticed that your XA
> > implementation does not formally implement javax.sql.DataSource. I felt
> > pretty sure that this was a simple oversight, given that BaseDataSource
> > provides complete compatibility with the DataSource interface. I
> patched
> > thusly:
>
> I'm not sure that's a smart a smart thing to do. I don't think there's a
> requirement for XADataSource implementations to implement DataSource as
> well. If that was the case, surely XADataSource interface would inherit
> DataSource to enforce that. If we declare that PGXADataSource implements
> DataSource, then one can erroneously configure the container to use
> PGXADataSource in normal DataSource-mode. In fact I suspect that's the
> case in your environment as well.
>
> Can you provide a simple test case involving Hibernate so that I can try
> this out myself? What's in your hibernate config file?
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PGXADataSource does not implement DataSource
@ 2007-04-20 21:16 Heikki Linnakangas <heikki@enterprisedb.com>
parent: Bill Middleton <utvikler@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2007-04-20 21:16 UTC (permalink / raw)
To: Bill Middleton <utvikler@gmail.com>; +Cc: books@ejurka.com; pgsql-jdbc
Bill Middleton wrote:
> Hello again, and thanks for the feedback. Yes, I'm likely in way over my
> head here. However, things are working acceptably with minimal testing so
> far. I register my modified PGXA as the resource in a
> UserTransactionService and then pass it into hibernate via jndi lookup,
> along with a transactionmanager. The interesting bits of
> hibernate.cfg.xmlare then:
>
> <property name="hibernate.dialect">
> org.hibernate.dialect.PostgreSQLDialect</property>
> <property name="hibernate.connection.datasource
> ">java:comp:myDS</property>
> <property name="hibernate.transaction.factory_class">
> org.hibernate.transaction.JTATransactionFactory</property>
>
> Hibernate accesses the DS in
> org.hibernate.connection.DataSourceConnectionProvider
>
> I'm using the atomikos TM, and sharing the DS between hibernate and a
> (also
> slightly modified) up jboss cache.
I'm not an expert on hibernate or atomikos, but I don't think hibernate
should ever see the raw PGXADataSource object. Whatever is handling the
connection pool, either Atomikos or JBoss, should get a connection from
the XADataSource object, and wrap that in a DataSource implementation of
it's own. That wrapper object is registered in JNDI, and hibernate gets
it from there.
Where is the connection pool configured? What's in the jboss cache and
how is it modified?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Fwd: PGXADataSource does not implement DataSource
@ 2007-04-20 22:07 Bill Middleton <utvikler@gmail.com>
parent: Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 0 replies; 6+ messages in thread
From: Bill Middleton @ 2007-04-20 22:07 UTC (permalink / raw)
To: books@ejurka.com; pgsql-jdbc
I accidentally left the list out of this reply.
---------- Forwarded message ----------
From: Bill Middleton <utvikler@gmail.com>
Date: Apr 21, 2007 12:05 AM
Subject: Re: [JDBC] PGXADataSource does not implement DataSource
To: Heikki Linnakangas <heikki@enterprisedb.com>
Heikki wrote:
> I'm not an expert on hibernate or atomikos, but I don't think hibernate
> should ever see the raw PGXADataSource object. Whatever is handling the
> connection pool, either Atomikos or JBoss, should get a connection from
> the XADataSource object, and wrap that in a DataSource implementation of
> it's own. That wrapper object is registered in JNDI, and hibernate gets
> it from there.
Hibernates JTA implementation does use the ordinary usertransaction from
atomikos (or jboss, presumably) as bound in jndi, but it seems to require
the actual datasource to obtain initial information about the db, and
possibly to create table automatically. If I omit it, I get exceptions for
not supplying a jdbc connection. And indeed, the XADataSource cast to
DataSource is cached in DataSourceConnectionProvider, its getConnection()
method is called by several internal classes - but nowhere does it specify
an XAConnection or XAResource so....
I guess I'll slink off and test this a bit more, before I conclude that its
stable.
Thanks again,
Bill Middleton
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2007-04-20 22:07 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-20 20:00 PGXADataSource does not implement DataSource Bill Middleton <utvikler@gmail.com>
2007-04-20 20:26 ` Kris Jurka <books@ejurka.com>
2007-04-20 20:32 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-04-20 20:56 ` Bill Middleton <utvikler@gmail.com>
2007-04-20 21:16 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-04-20 22:07 ` Bill Middleton <utvikler@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox