Connection and Self-Servicing

Posts   
 
    
llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 02-Jun-2010 08:55:28   

I'm using Self-Servicing and the Oracle odp.net driver with llbl 2.5. This cannot be changed.

I need to execute a command (set some Oracle roles) before a connection is used. This of course I'll like to write only once. Can this be done?

LLBL creates a new connection on every query (if you do not use transactions). Can this be changed so I can provide the connection?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 02-Jun-2010 10:04:47   

I'd have recommended using Adapter, as it gives you more control over the internal workings.

Anyway, I think the following thread can be helpful: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16658 (Check the last post).

Also you can get a connection from DBUtils as follows:

OracleConnection connection = DbUtils.CreateConnection())
llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 02-Jun-2010 10:35:09   

Walaa wrote:

I'd have recommended using Adapter, as it gives you more control over the internal workings.

Anyway, I think the following thread can be helpful: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16658 (Check the last post).

Also you can get a connection from DBUtils as follows:

OracleConnection connection = DbUtils.CreateConnection())

It is legacy code and therefore I cannot change to Adapter scenario.

I'm not quite sure what to use from the referred thread. Do you mean that I should start a transaction? This indeed will preserve the connection over multiple fetches. But won’t it hurt the database performance, if I keep a long running transaction just to fetch rows? (There are no inserts and updates)

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 02-Jun-2010 14:04:21   

And what's wrong about using this:

OracleConnection connection = DbUtils.CreateConnection())
llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 02-Jun-2010 14:16:38   

Walaa wrote:

ANd what's wrong about using this:

OracleConnection connection = DbUtils.CreateConnection())

Nothing wrong about that, but when fetching afterwards a new connection is created under the hood.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 03-Jun-2010 09:26:30   

Please see: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16850&StartAtMessage=0&#94863

Not sure if it works in 2.5, I do know that it does work in v2.6, some people use this in SelfServicing exactly the way you intended. Hopefully you are helped with the link/guide mentioned above.

In any way, I'd go for the simpler route with an ITransaction implementation or a subclass of the Transaction and use that. The reason is that you have to control your connection anyway, and with the transaction class you can do so.

Frans Bouma | Lead developer LLBLGen Pro
llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 03-Jun-2010 16:35:22   

Otis wrote:

Please see: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16850&StartAtMessage=0&#94863

Not sure if it works in 2.5, I do know that it does work in v2.6, some people use this in SelfServicing exactly the way you intended. Hopefully you are helped with the link/guide mentioned above.

In any way, I'd go for the simpler route with an ITransaction implementation or a subclass of the Transaction and use that. The reason is that you have to control your connection anyway, and with the transaction class you can do so.

This seems to work, thanks! Do you know how to set the transaction in the folowwing query?

MyEntity e = new MyEntity (1);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 03-Jun-2010 16:47:01   

llblstc wrote:

Otis wrote:

Please see: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16850&StartAtMessage=0&#94863

Not sure if it works in 2.5, I do know that it does work in v2.6, some people use this in SelfServicing exactly the way you intended. Hopefully you are helped with the link/guide mentioned above.

In any way, I'd go for the simpler route with an ITransaction implementation or a subclass of the Transaction and use that. The reason is that you have to control your connection anyway, and with the transaction class you can do so.

This seems to work, thanks! Do you know how to set the transaction in the folowwing query?

MyEntity e = new MyEntity (1);

Transaction t = new Transaction(...); MyEntity e = new MyEntity(); // no fetching yet t.Add(e); e.FetchByPk(1);

Frans Bouma | Lead developer LLBLGen Pro
llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 03-Jun-2010 18:22:12   

Thanks Otis.

Unfortunately I was to quick. I thought I could create my own ITransaction Type which shouldn't even start a real Oracle Transaction. The ITransaction Type only purpose would be to hold the connection so every query uses the same connection. But unfortunately LLBL creates a connection under the hood anyway. Should it be possible?

llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 04-Jun-2010 09:32:25   

Please write if I should elaborate

llblstc
User
Posts: 19
Joined: 06-Jul-2009
# Posted on: 04-Jun-2010 09:41:50   

my bad, I just needed to implement the interface correct.

I was missing:

    public void Add(ITransactionalElement participant)
    {
        participant.Transaction = this;
    }