Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Will EclipseLink work in a true autocommit environment?

Thanks James!

I'm sitting pretty in my odd little environment now. Even though it's
simple, I figure it's worth documenting for future generations of

Here's what I did, I implemented SessionCustomizer like this:

public class AutoCommitCustomizer implements SessionCustomizer {
	  public void customize(Session session) {
        DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();


Then when I set up my EntityManagerFactory I put:


Worked great!

Thanks again!


On Thu, May 15, 2008 at 9:03 AM, James Sutherland <jamesssss@xxxxxxxxx> wrote:
> You can customize the DatabaseLogin using a SessionCustomizer specified in
> your persistence.xml.  You can access the login from the session
> (session.getLogin()).
> SessionCustomizer is currently in the (wrong) package
> "org.eclipse.persistence.internal.sessions.factories".
> It can be set through the persistence.xml property,
> "eclipselink.session.customizer".
> Tim Hollosy wrote:
>> Ok, since I'm creating my connection with the JDBC properties in my
>> persistence unit, the only way I could think to get at the
>> DatabaseLogin was getting it from my session in my EM before I start
>> it, however calling em.begin() still causes it to create a transaction
>> on the database, I guess i'll have to dig in to the code a bit more.
>> This really isn't a show stopper for me, but I'd be interested if it's
>> possible.
>> Thanks
>> On Wed, May 14, 2008 at 9:36 AM, Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
>>> Thanks, we'll try this out and yes it is an odd design choice I admit.
>>> But the world of fat clients is odd! It's a decision that has to be
>>> made, the trade off between each client holding it's own connection
>>> pool or all of them sharing a set of transactionless connections on a
>>> proxy.
>>> Really we get around it by manually controlling when things hit the
>>> database with the flush type on commit.
>>> What I mean by work, is will I still be able to use a UnitOfWork with
>>> begin/commit/rollback statements without actually using my database's
>>> (postgres) transactions.
>>> I don't really see how to use this DatabaseLogin class though, after
>>> construction what class consumes it?
>>> Thanks,
>>> Tim
>>> On Wed, May 14, 2008 at 9:16 AM, James Sutherland <jamesssss@xxxxxxxxx>
>>> wrote:
>>>> Not sure what you mean by "work".  EclipseLink will begin and commit
>>>> transactions where required.  If your database does not support
>>>> transactions
>>>> then (if it silently ignores JDBC commit()) you will just not get any
>>>> transaction semantics.  If it throws an error on JDBC commit() then it
>>>> will
>>>> not work, you could disable EclipseLink from processing transactions
>>>> (DatabaseLogin.setUsesExternalTransactionController(true)), but it would
>>>> seem to be an odd design choice to be using a database configuration
>>>> that
>>>> does not support transactions.
>>>> MySQL does support transactions.
>>>> Tim Hollosy wrote:
>>>>> I'm using EclipseLink with a non jta datasource, due to some weird
>>>>> proxy stuff I have to stay in autocommit mode. I thought that was
>>>>> working fine, but now that we're in heavier test mode I see that
>>>>> EclipseLink is turning autocommit off when beginning a transaction,
>>>>> and back on again after a commit.
>>>>> I thought that EclipseLink's transactions were independent of the
>>>>> database, but apparently I was mistaken.
>>>>> So my question is, is it possible for EclipseLink to work in a true
>>>>> autocommit environment? I assumed it would because it works with mysql
>>>>> (we're in postgres behind a proxy, and our proxy version doesn't
>>>>> support transactions).
>>>>> --
>>>>> ./tch
> -----
> ---
> James Sutherland
>  EclipseLink ,
> TopLink
> Wiki: EclipseLink ,
> TopLink
> Forums: TopLink ,
> EclipseLink
> Book: Java Persistence
> --
> View this message in context:
> Sent from the EclipseLink - Users mailing list archive at
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx


Back to the top