Re: Isolation level

2008-02-20 Thread Armin Waibel

Hi Christian,

Christian Lipp wrote:

Hi Armin,

thank you for  quick answer and sorry for my long delay.

We are using an older OJB version (1.0.1.x), so I thought I cannot use your
recommendation and wanted to perform a backport now.
I got the actual OJB now and examined it, but also couldn't find an
attribute in the jdbc-connection-descriptor (I checked the repository.dtd).

So I asume I have to implement the JDBC transaction level as attribute for
jdbc-connection-descriptor into OJB or do I miss something?


Some databases support transaction-isolation settings by append a
property in the database URL - e.g. maxDB:
dbalias="//localhost/ojb?isolation=TRANSACTION_READ_COMMITTED

Additionally you can specify connection/database properties as custom 
attributes with prefix "jdbc.".






OJB will set these properties (with jdbc.* prefix) when create the 
connection:

Connection con = DriverManager.getConnection(url, properties);




Could someone point me in the right direction for this implementation? I
assume I have to read the attribute and apply it in the function
PlatformDefaultImpl.initializeJdbcConnection.



If your database doesn't support isolation setting shown above, you can 
indeed extend a existing Platform class and override 
#initializeJdbcConnection. Within this method you can easily get custom 
attributes using:



   


class PlatformMyOwnImpl extends PlatformMySQLImpl{
...
public void initializeJdbcConnection(Connection conn)
{
  String isolation = jcd.getAttribute("isolation", null);
...
}
}

All shown solutions will work with latest OJB source
http://www.mail-archive.com/ojb-user%40db.apache.org/msg16078.html
I don't check the older versions.

regards,
Armin


Thanks in advance, CL

-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED] 
Sent: Freitag, 25. Jänner 2008 03:03

To: OJB Users List
Subject: Re: Isolation level

Hi Christian,

Christian Lipp wrote:
I am still looking for an solution for my lock level settings and 
therefore I am digging through the OJB source.


What I am not sure at the moment is if the setting of the 
isolation-level is generally ignored in OJB?



I couldn't find the place in the OJB code where the isolation level is 
set to the DescriptorRepository and later to the connection.

In my optionion the isolation-level in the XML file is ignored.

Could someone point me in the right direction?


Out of the box the isolation-level setting is only used by the ODMG-api
which use pessimistic locking by default.
http://db.apache.org/ojb/docu/guides/lockmanager.html#Pessimistic-Locking
The PB-api doesn't use pessimistic locking, thus it will ignore these
settings.

The database transaction levels are completely independent from the
isolation-level setting in OJB. So you can use different database
transaction levels (e.g. as property in the dbalias attribute in the
jdbc-connection-descriptor)

regards,
Armin


Thanks in advance,
CL




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Mapping a List (or Set) with OJB.

2008-02-20 Thread Armin Waibel

Hi Johan,

Johan Andersson wrote:

Greetings!

Say I have a class MyClass it looks like this:

public class MyClass {
   private int id;
   private String name; private List myIntegers = new 
ArrayList;


   /* getters and setters omitted ... */
}


What options do I have if I want to persist this class using OJB?

The List is causing me problems since it is not a pesistent 
entity class.
Requirements impede me from just putting it into one field and use a 
IntList2VarcharFieldConversion.
Requrements want me to have the List data in a separate 
database table.

But I just cant figure out how to map this.


Sorry, to have the List data in a separate database table is
not supported by OJB. In this case OJB expect a persistence capable
class e.g. Items.

regards,
Armin



Here's my tables (I am using MySQL):
CREATE TABLE `MY_CLASS` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` varchar(255) NOT NULL,
 PRIMARY KEY  (`id`)
);
CREATE TABLE `ITEMS` (
 `my_class_id` int(10) unsigned NOT NULL,
 `item_id` int(10) unsigned NOT NULL,
 PRIMARY KEY (`my_class_id`, `item_id`)
);


Thankful for any suggestions.
/JOHAN

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]