Re: Mysql deadlock / timeout - fixed I hope

2004-12-02 Thread Jin Bal
We found that there is a bug with MySQL 4.0.20 that causes deadlocks in 
transactions

we have upgraded thanks for the responses
- Original Message - 
From: Robert S. Sfeir [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Tuesday, November 30, 2004 5:53 PM
Subject: Re: Mysql deadlock / timeout


Huh is OJB competing with some other processes trying to update the same
table/db?  It looks like it's complaining that it can't get a lock on row,
and what ever process is not giving it up.
Make also sure that all your transactions end by closing the PB instance.
I would add some debugging info to see which record is being updated at 
the
time, with a timestamp to tell you when it was happening, and I would try 
to
catch this specific exception and resubmit the update again once or twice
before failing, if there indeed is another process updating the DB.

Last thought... Is it around a time when you have a DB backup going on?
Some backups make the db/table read only, and that could be a problem.
HTH
R
On 11/30/04 12:43 PM, Jin Bal [EMAIL PROTECTED] wrote:
Hello
I have an app in production that occasionally suffers from what seems to 
be a
deadlock or timout when doing a simple update inside a transaction

here is the stacktrace - can anyone shed any light on things??
TIA
Caused by: org.apache.ojb.broker.PersistenceBrokerSQLException:
java.sql.SQLException: Deadlock found when trying to get lock; Try 
restarting
transaction, message from server: Lock wait timeout exceeded; Try 
restarting
transaction

at 
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeUpdateSQL(Unknown
Source)

at org.apache.ojb.broker.core.MtoNBroker.deleteMtoNImplementor(Unknown 
Source)

at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeAndLinkMtoN(Unknown
Source)

at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Unknown
Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown 
Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
at 
com.buyacar.dtofactory.OJBTransactionImpl.save(OJBTransactionImpl.java:54)

at com.buyacar.dtofactory.UserFactory.saveUser(UserFactory.java:28)


-
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]


Mysql deadlock / timeout

2004-11-30 Thread Jin Bal
Hello 

I have an app in production that occasionally suffers from what seems to be a 
deadlock or timout when doing a simple update inside a transaction

here is the stacktrace - can anyone shed any light on things??

TIA

Caused by: org.apache.ojb.broker.PersistenceBrokerSQLException: 
java.sql.SQLException: Deadlock found when trying to get lock; Try restarting 
transaction, message from server: Lock wait timeout exceeded; Try restarting 
transaction

at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeUpdateSQL(Unknown 
Source)

at org.apache.ojb.broker.core.MtoNBroker.deleteMtoNImplementor(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeAndLinkMtoN(Unknown 
Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Unknown 
Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)

at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)

at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)

at com.buyacar.dtofactory.OJBTransactionImpl.save(OJBTransactionImpl.java:54)

at com.buyacar.dtofactory.UserFactory.saveUser(UserFactory.java:28)




repository.xml performance tuning best practice

2004-11-18 Thread Jin Bal
Hi

I have an OJB project in poroduction which runs fairly well.  I am now 
interested in tuning OJB's performance / efficiency as I know that my vanilla 
mapping is not as optimised as it should be (i.e. lazy loading etc).

Are there any general (I understand that this issue is quite specific to the 
app concerned) guidelines or best practices on how to get the most out OJB in 
production

TIA

Jin

Re: Negative Sequence Numbers?

2004-07-30 Thread Jin Bal
I'm not convinced i've got it working yet as all i've done is upgraded in
hope of fixing it.
- Original Message -
From: Robert Crawford [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 30, 2004 4:10 AM
Subject: Re: Negative Sequence Numbers?


 Charles N. Harvey III said:
  It means that something isn't set correctly in the database.
  This has happened to me many times.  It always happens when I turn on
 native sequencing (IDENTITY in MSSQL or AUTOINCREMENT in MySql).
 Check the PK of your database, it might not be properly set to
 increment. Whenever
  this isn't set properly I get -1 and -2 for sequence numbers all the
time.

 The database is OK -- I tested it directly, and it assigns sequence
 numbers correctly.

 This is the code; I've added transaction calls for the PB-api, but the
 table I'm using this with doesn't have transactions enabled, so those are
 effectively just null-ops:

 broker =
 PersistenceBrokerFactory.createPersistenceBroker(getPbKey());
 broker.beginTransaction();


 // 1. make sure no user with that username exists
 Criteria c = new Criteria();
 c.addEqualTo(emailAddress, username);
 Query q = QueryFactory.newQuery(getUserInstanceClass(), c);
 Collection col = broker.getCollectionByQuery(q);
 if (col.size()  0) {
 throw new DuplicateUsernameException(username);
 }

 // 2. create the new user and return its object
 User user = (User) getUserInstanceClass().newInstance();
 user.setEmailAddress(username);
 user.setPassword(password);
 user.setFirstName(firstName);
 user.setLastName(lastName);
 broker.store(user);

 broker.commitTransaction();

 Here's the class descriptor:

 class-descriptor
 class=com.kloognome.accesscontrol.ojb.UserInstance
 table=ac_users
 field-descriptor name=userNbr column=user_nbr jdbc-type=INTEGER
 primarykey=true autoincrement=true access=readonly/
 field-descriptor name=emailAddress column=email_address
 jdbc-type=VARCHAR/
 field-descriptor name=password column=password
 jdbc-type=VARCHAR/ field-descriptor name=firstName
 column=first_name
 jdbc-type=VARCHAR/
 field-descriptor name=lastName column=last_name
 jdbc-type=VARCHAR/
 /class-descriptor

 I'm using the 1.0.0 release of OJB, if that matters.

 I've tried re-creating the table with the auto_increment and primary
 key attributes reversed on the table definition; that didn't change
 anything. I've tried forcing the userNbr field on the object to zero; that
 didn't change anything.

 Any ideas?



 --
 In discussing [terrorists], 'Capturing their hearts and minds' only makes
 sense if by that you mean, literally, capturing their hearts and minds and
 putting them in mason jars. -- Jonah Goldberg


 -
 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: Negative Sequence Numbers?

2004-07-29 Thread Jin Bal
I've been experiencing the same problem but running on just Tomcat.

what version of OJB are you using

What DB.

I was using RC5 and MySQL

i've upgragded and have stopped getting the error in my dev env but have
yert to test on the integration server.

Cheers
Jin

- Original Message -
From: Vesely, Maxim [IT] [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Thursday, July 29, 2004 2:11 PM
Subject: RE: Negative Sequence Numbers?


I experienced exactly the same problem running in managed environment with
JTA transaction.

Max.

-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 29, 2004 8:35 AM
To: OJB Users List
Subject: Re: Negative Sequence Numbers?


Robert Crawford wrote:

 Armin Waibel said:

Robert Crawford wrote:


Armin Waibel said:


Do you only use the PB-api? This bug is odmg-api related.


I only use the PB-api.


Then you shouldn't get problems with negative sequence numbers.
Can you describe me with some pseudo code an test case to reproduce your
problem?



Don't you use transaction demarcation or is this code snip from an
managed environment with JTA transaction?

Armin

From memory, the code looks something like this:

 PersistenceBroker broker =
 PersistenceBrokerFactory.createPersistenceBroker(pbKey);
 User user = new User();
 user.setEmailAddress(emailAddress);
 // more setters here, nothing that touches the primary key
 broker.store(user);

 At this point the database has a negative number for the primary key and,
 from what I can recall from my debugging, the user object has zero in the
 primary key field.

 Here's the start of the class descriptor:

 class-descriptor
 class=com.kloognome.accesscontrol.ojb.UserInstance
 table=ac_users
 field-descriptor name=userNbr column=user_nbr jdbc-type=INTEGER
 primarykey=true autoincrement=true access=readonly/



 -
 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: sequencemanagernative and mysql

2004-07-07 Thread Jin Bal
At the moment it is not causing side effects as there is no key collision
(yet) - I was wondering whether this was expected behaviour.

My understanding is that OJB uses a temp negative PK before insert.  does it
then lookup the db generated one and set it in  the persistent object durign
the afterStore() operation?

Haven't got any code to post right now (will follow shortly)  could there be
an issue with the cache (i.e not flushing after insert)?

Thanks
Jin


- Original Message -
From: Armin Waibel [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Tuesday, July 06, 2004 5:57 PM
Subject: Re: sequencemanagernative and mysql


 Hi Jin,

 Jin Bal wrote:
  I'm finding that the PK field with autoincrement are negative numbers -
is this normal behaviour or is somehting up?
 

 hmm, the negative values are temporary used before the object was
 written to DB.
 See here

http://db.apache.org/ojb/docu/guides/sequencemanager.html#Identity+based+seq
uence+manager

 Does it cause side-effects in your environment? Could you post some
 pseudo code to show the problem?

 regards,
 Armin

  TIA
  Jin

 -
 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: sequencemanagernative and mysql

2004-07-07 Thread Jin Bal
Hi Armin

I'm not using the ODMG API so I can't confirm this for you, I'm using PB
only.  The only object that the app CRUD's (via OJB) is the User object.

We did notice that this issue is intermittent and stopped for a while but
then started up again.


- Original Message -
From: Armin Waibel [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Wednesday, July 07, 2004 10:53 AM
Subject: Re: sequencemanagernative and mysql


 Hi Jin,

 Jin Bal wrote:
  At the moment it is not causing side effects as there is no key
collision
  (yet) - I was wondering whether this was expected behaviour.
 
  My understanding is that OJB uses a temp negative PK before insert.
does it
  then lookup the db generated one and set it in  the persistent object
durign
  the afterStore() operation?
 

 yep! I made some tests with PB-api and ODMG-api and it seems that when
 using the odmg api + SequenceManagerNativeImpl + main object with single
 reference, the FK set in the main object be wrong (negative value). Is
 this your problem too?


  Haven't got any code to post right now (will follow shortly)  could
there be
  an issue with the cache (i.e not flushing after insert)?
 

 normally the object will be stored to cache after the afterStore() call.

 regards,
 Armin


  Thanks
  Jin
 
 
  - Original Message -
  From: Armin Waibel [EMAIL PROTECTED]
  To: OJB Users List [EMAIL PROTECTED]
  Sent: Tuesday, July 06, 2004 5:57 PM
  Subject: Re: sequencemanagernative and mysql
 
 
 
 Hi Jin,
 
 Jin Bal wrote:
 
 I'm finding that the PK field with autoincrement are negative numbers -
 
  is this normal behaviour or is somehting up?
 
 hmm, the negative values are temporary used before the object was
 written to DB.
 See here
 
 
 
http://db.apache.org/ojb/docu/guides/sequencemanager.html#Identity+based+seq
  uence+manager
 
 Does it cause side-effects in your environment? Could you post some
 pseudo code to show the problem?
 
 regards,
 Armin
 
 
 TIA
 Jin
 
 -
 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: sequencemanagernative and mysql

2004-07-07 Thread Jin Bal
The code that saves the object is simply

broker.store(object);

thats it.

BTW i'm still using  RC5.

Jin




- Original Message -
From: Jin Bal [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Wednesday, July 07, 2004 8:25 AM
Subject: Re: sequencemanagernative and mysql


 At the moment it is not causing side effects as there is no key collision
 (yet) - I was wondering whether this was expected behaviour.

 My understanding is that OJB uses a temp negative PK before insert.  does
it
 then lookup the db generated one and set it in  the persistent object
durign
 the afterStore() operation?

 Haven't got any code to post right now (will follow shortly)  could there
be
 an issue with the cache (i.e not flushing after insert)?

 Thanks
 Jin


 - Original Message -
 From: Armin Waibel [EMAIL PROTECTED]
 To: OJB Users List [EMAIL PROTECTED]
 Sent: Tuesday, July 06, 2004 5:57 PM
 Subject: Re: sequencemanagernative and mysql


  Hi Jin,
 
  Jin Bal wrote:
   I'm finding that the PK field with autoincrement are negative
numbers -
 is this normal behaviour or is somehting up?
  
 
  hmm, the negative values are temporary used before the object was
  written to DB.
  See here
 

http://db.apache.org/ojb/docu/guides/sequencemanager.html#Identity+based+seq
 uence+manager
 
  Does it cause side-effects in your environment? Could you post some
  pseudo code to show the problem?
 
  regards,
  Armin
 
   TIA
   Jin
 
  -
  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: Concurrency question

2004-07-07 Thread Jin Bal
I think using the optimistic offline lock approach will be sufficient for
your needs.

There is doc on the OJB site. but basically any update increments a version
number which ojb checks and compares to the version it's about to save and
throws an exception which indicates that there is a concurreny conflict.

You can detect this and tell the user that someone else is editing the same
thing and let them decide how to proceed.

HTH

Jin

- Original Message -
From: Fiona Magner [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 06, 2004 5:00 PM
Subject: Concurrency question


Hi there:

I am just beginning to use OJB in a Web application. The particular web
application (when it goes live with OJB) will be required for high
availability. I have a question about a concurrency issue that I have come
across. Consider the following example. Two users, a and b are accessing the
customers table and updating the customers balance.


// 1.User A gets customer record 123 (bean) from database.
Customer has balance of 0

// 2. User B gets customer record 123 (accountbalance = 0)

// 3.User A make changes to bean object using retrieved values
eg. c.setAccountbalance(c.getAccountbalance() + 20.00)
(customer will now have balance of 20)

// 4. User B makes changes to account balance (balance now 20)

// 5. User A sends updates to database (stored balance is now 20)

// 6. User B sends updates to database (stored balance is now 20 ***
should be 40)

Note that steps 1, 3 and 5 actually all happen within the one script (as do
2, 4 and 6) but I have just outlined them as separate steps above for
clarity. As you can see it is possible for two concurrent users to cause
inconsistency in the data. Is it necessary to have a markDirty() step in the
script before applying the changes? Also can you tell me if this markDirty()
will put a lock on the table until the changes are committed? Like I say
this will be a high throughput site and therefore I would like to avoid any
lengthy locks on the tables while updates are being carried out. I hope my
email is clear, if you require any more info please let me know.

Thanks!
Fiona


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



sequencemanagernative and mysql

2004-07-06 Thread Jin Bal
I'm finding that the PK field with autoincrement are negative numbers - is this normal 
behaviour or is somehting up?

TIA
Jin

Re: problem with MySQL driver

2003-10-24 Thread Jin Bal
try
dbalias=//localhost:3306/default?reconnect=true


- Original Message -
From: Ramon Cano Granizo [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Friday, October 24, 2003 8:59 AM
Subject: problem with MySQL driver


Hello, I'm working with ojb rc4, MySQL 4.0, a jdbc driver from MySQL
(mysql-connector-java-3.0.9-stable-bin) and Tomcat 3.3.

The problems comes when the application it's sometime without resolving any
request (about two hours), then, the next request throw a
StackOverflowException, the trace show  the driver opening and closing
connection, could someone help me?

It's something wrong in the repository_database.xml (here is), perhaps
jdbc-lever??

jdbc-connection-descriptor
jcd-alias=databaseMySQL
default-connection=true
platform=MySQL
jdbc-level=2.0
driver=com.mysql.jdbc.Driver
protocol=jdbc
subprotocol=mysql
dbalias=//localhost:3306/default
username=root
password=
   


   connection-pool
maxActive=21
validationQuery= /
:-(

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



Re: storing a new object fails

2003-09-26 Thread Jin Bal
try leaving the PK empty - I thnk that OJB works out whether its a insert or
update by the presence of this field

There may be a way to force an insert but I can't remember it right now

Jin
- Original Message -
From: Durham David Contr 805 CSPTS/SCBE [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 26, 2003 3:49 PM
Subject: storing a new object fails


I'm writing a routine that clears out a db and reloads a defined test
data set.  I'm trying to insert new objects but sometimes, not always,
OJB will execute an update statement instead of an insert.  I'm
explicitly setting the id pk's and bypassing the sequencemanager, so I
figure that has something to do with it, but I can't explain the
discrepancy.  Can anyone point me to the likely cause of this?

Thanks,


Dave



-
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: Partial collection problem

2003-07-09 Thread Jin Bal
I've had this problem too.

The issue is that the result set is being closed prematurely because the
eager-release attribute in the connection descriptor was set to true;

if you can try setting this to false.  I was able to do this without any
probs because I'nm using tomcat, the problem appeared because i tried to
port to jboss and changed the eager release setting.

cheers

Jin
- Original Message -
From: McCaffrey, John G. [EMAIL PROTECTED]
To: 'OJB Users List' [EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 3:46 PM
Subject: RE: Partial collection problem


 Rob,
 I have had this problem to, and posted all the info that I could to try to
 diagnose the issue, to no avail. I ended up just coding a work around to
get
 what I needed.
 I noticed that when I ran a query to get the count of expected objects,
the
 count I got back was right, but the collection was always n+1 (just as you
 described).
 For the workaround I first get an enumeration of primary keys (because
that
 works as expected), then go through each of the referenced tables, and
build
 a hashmap of the rest of the objects that I need. Then I piece them
together
 at the end, and return a collection of 'Whole' objects. I think its
actually
 faster than the OJB code would have been, because its fewer trips to the
DB.

 I had to do this workaround, even though it is a little clunky, because we
 are going to production soon, and I wasn't able to solve the original
 Collection problem. I only have one class with a collection, so I only had
 to do the workaround once. I am hoping that the issue gets resolved,
because
 I don't want to have to code any more OJB workarounds, and I don't want to
 abandon OJB when we move to the next project.

 Are you able to determine what the issue is?
 Previous postings pointed to JBoss issues, but I have websphere and DB2
(my
 issue could be my JDBC driver, I haven't tried any others).

 It seemed to me that a resultSet was being closed early.

 please post if you resolve the issue

 -John

 -Original Message-
 From: Rob Kischuk [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, July 09, 2003 7:09 AM
 To: 'OJB Users List'
 Subject: RE: Partial collection problem


 Thanks for the suggestion.  I built from the latest code in CVS last
night,
 and still had the same problem.

 -Rob

 -Original Message-
 From: Armin Waibel [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 07, 2003 7:23 PM
 To: OJB Users List
 Subject: Re: Partial collection problem

 Hi Rob,

 I think this is an known issue, please try
 latest CVS.

 regards,
 Armin

 - Original Message -
 From: Rob Kischuk [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, July 07, 2003 3:31 PM
 Subject: RE: Partial collection problem


  This is a big problem - we have a collection of 200 items that we are
  retrieving, and the first query only retrieves a single item, with
 each
  subsequent query retrieving one more item (e.g. - the fifth query
 result has
  5 items).
 
  This seems to be either a very nasty error on my part, or a major bug.
 Can
  anyone shed some additional light on this?  Is it a bug?  Is there a
  workaround?  This is a major showstopper for OJB on an application
 we're
  working on, and could require some major rework.
 
  -Rob
 
  -Original Message-
  From: Rob Kischuk
  Sent: Thursday, July 03, 2003 9:43 AM
  To: '[EMAIL PROTECTED]'
  Subject: Partial collection problem
 
  I saw a discussion cross this list a while back regarding this same
 problem,
  but with no solution.  The problem is this:  when I run a query to
 load a
  collection of objects that contain other objects, the first call
 retrieves
  only the first item in the collection.  The second call retrieves a
 total of
  2 items, the third, a total of 3 items, and so on.  Obviously, the
 correct
  functionality would be to have all of the items in the collection
 retrieved
  on the first call.
 
 
 
  I described the issue in great detail as a part of Defect OJB172:
 
 http://scarab.werken.com/issues/curmodule/120/tqk/0/template/ViewIssue.v
 m/id
  /OJB172/issuelist/-1/issuelist/1/issuelist/OJB172
 
 http://scarab.werken.com/issues/curmodule/120/tqk/0/template/ViewIssue.
 vm/i
  d/OJB172/issuelist/-1/issuelist/1/issuelist/OJB172
 
 
 
  But it appears that the defect hasn't been touched since I entered it.
 Is
  there a known fix or workaround for it?
 
 
 
  Thanks!
 
  Rob
 
 
  -
  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: Re[2]: RsIterator question

2003-07-02 Thread Jin Bal
The approach I take is to limit the number of rows returned and page the
results.

This can be acheived by setting startAt and endAt indexes on the Query
object, then you just have to keep track of the page you're on and work out
the start and end index depending on how many you'er displaying on each page

also means that you don't have to pass iterators etc to the jsp page keeping
you're architecture simpler - you just return the 20 long collection of
materialised objects

HTH

Jin


- Original Message -
From: Alexander Prozor [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]; Mykola Ostapchuk
[EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 3:39 PM
Subject: Re[2]: RsIterator question


 Hello Mykola,

 Wednesday, July 2, 2003, 5:27:39 PM, you wrote:

 MO The main reason I'm using getIteratorByQuery is because my DB table is
 MO pritty big (~100 000 records). Putting all the records into Collection
is
 MO too memory expensive.

 MO I'll very appreciate any help of dealing with big DB tables.
 you can use Proxy for your collection.


 --
 Best regards,
  Alexandermailto:[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: How Do Others Use OJB With DTO's and Business Objects?

2003-06-24 Thread Jin Bal
I also wrestled with these design and patterns.

In the end I dumped the business object (well I dumped the DTO's actually)
because copying between them was very tedious - OJB handles that for you
throught the mappings (so why do it again i thought).  I don't see anything
wrong with this approach as long as you hide OJB from the rest of your
layers (after all they can't see your business objects can they?).

The benefit of OJB is that it is transparent so your Bo's/DTO'/Vo's
(whatever you've called them! ;-) are just pojo's

Once i took this approach my development speed increased and I stopped
fighting the architecture.

I Still however do translations between the view layer and the business
delegate layer and use DTO's to transfer the from http requests (after
they've been validated and typed cast etc) to the business layer and back
again.

HTH

Jin

- Original Message -
From: Shane Mingins [EMAIL PROTECTED]
To: 'OJB Users List ' [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2003 9:06 AM
Subject: How Do Others Use OJB With DTO's and Business Objects?


 Hi All

 I just wondered how others are implementing their persistence layers using
 OJB?

 This is what I am looking at doing at the moment but I am wondering
whether
 or not it makes sense?

 I have a Data Access Class (DAO) that provides access to a Data Transfer
 Object (DTO) like:

 CustomerDAO with methods insert(CustomerDTO), update(CustomerDTO),
 getByName(String) etc.

 So the way I am viewing it is, any returned object from the CustomerDAO
 would be a DTO.  And anything passed to it would be a DTO.

 Within the CustomerDAO, any interaction with OJB (FYI using ODMG) is done
 via BusinessObjects.

 So a getByName(String) will query the database using OJB, return a
 CustomerBusinessObject to the CustomerDAO which will populate a
CustomerDTO
 and return it to caller.

 An insert with provide a CustomerDTO to the CustomerDAO which will inturn

 create a CustomerBusinessObject and persist it.

 An update will provide a CustomerDTO to the CustomerDAO which will inturn
 get the existing CustomerBusinessObject, update it from the CustomerDTO
and
 persist the changes.

 Does this sound reasonable?

 It just seems like an awful lot of copying that becomes quite difficult
 when an Object contains a collection of other Objects.

 I have been using the BeanUtils.copyProperties() method to do my copying
but
 when it come to a collection I have to iterate through it otherwise the
 objects within the collection of the new DTO object [like returned in
 getByName()] would contain references to BusinessObjects and not DTO's.

 Any thoughts or comments?

 Cheers
 Shane

 -
 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: Limited collection returned

2003-06-03 Thread Jin Bal
Thanks for the detailed insight!

OJB172 was the bug I saw on the dev list#

I'll get back to about the eager-release when I get home.

Interestingly I've just realised that this bug began manifesting itself
after I attempted to port my setup to jboss 3.x from tomcat 4.x

I did attempt to back out the changes however I have a feeling that I left
the eager release attr set to true. I'll check later

watch this space

Thanks again

Jin
- Original Message -
From: Gary Richards [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Monday, June 02, 2003 3:05 PM
Subject: RE: Limited collection returned



 Hi everyone,

 Thought I'd offer my current observations on this as I work with Dan and
am running off the same codebase (JBoss 3.2.x, MySql, ODMG etc) and
therefore trying to crack the same problem.

 I've been using the eclipse debugger to step through the action of
invoking a query. I have spent most of the recent time observing
 private ManageableCollection getCollectionByQuery(Class collectionClass,
Class itemClass, Query query) of the PersistanceBrokerImpl class (line
1293), inparticular the actions of the while loop on line 1335 which reads
as,

  while (((endAt == Query.NO_END_AT_INDEX) || (retrievedCount 
numberOfObjectsToFetch))  iter.hasNext())

 I have witnessed the hasNext() call of this condition to return false
during the second cycle of the loop, even though I now there to be 13 rows
in the database table and 13 elements behind the Iterator. I have determined
this (for those who know eclipse) by editing the detail formatter of the
RSIterator class to read this.size() which shows 13 when I highlight it.

 This leads me onto RSIterator.hasNext() (line 216) which I have moved onto
observe as a result.
 I noticed that on the second cycle of the iterator, the call from within
hasNext() will issue

 hasNext = m_rsAndStmt.m_rs.next(); (line 223)

 This throws an expection which is caught by the same method so that false
is returned.

 catch (Exception ex)
 {
  hasNext = false;
 }

 I have noticed that the message given by this exception ex (which is not
logged, only gets caught) is Operation not allowed after ResultSet closed.
This certainly suggests that something has closed the ResultSet before the
iterator has been fininshed with (exactly what it says in the message ;) ).

 This almost always seems to happen after dependant objects have been
retieved as when we set auto-retrieve = false  in repository_user.xml for
the appropriate property we get all rows of the single table we query on but
no dependant objects, however when we set auto-retrieve = true  we get
only the first row of the single table and all its dependant objects.

 Is this possibly linked to the eager-release feature which needs to be
enabled for operation on JBoss, or a side effect of bug OJB172?

 Any other thoughts?

 regards

 Gary


 -Original Message-
 From: Dan Hanley
 Sent: Mon 02/06/2003 14:38
 To: OJB Users List
 Cc:
 Subject: RE: Limited collection returned



 Jin
 Are you also running in a managed environment (e.g. jBoss)?
 I suspect the bug you're referring to is:
 Type :Defect
 Issue Id :OJB172
 Reported by: Rob Kischuk
  rkischuk - (rkischuk at gttx.org)

 Details:

 Platform: PC
 Operating system: windows 2000
 Summary: Loading composite object leads to truncated collection
 Description: Repeated calls to retrieve a collection of objects that each
contain another object are
 retrieving truncated results, which are incrementally built to their
proper length using repeated
 requests.
 Status: New
 Priority: Undecided
 Severity: Major
 Functional area: Setup

 ... which sounds like it could be the culprit. A colleague of mine is
trying to trace through with the eclipse debugger to see if we can cast any
light on this.

 You are not alone, its holding a lot of people up...

 Dan

 -Original Message-
 From: Jin Bal [mailto:[EMAIL PROTECTED]
 Sent: Fri 30/05/2003 22:07
 To: OJB Users List
 Cc:
 Subject: Re: Limited collection returned



 I'm also having this problem - thank god someone else's said so !
it's been
 driving me mad ;-)

 i've been using ojb since 0.9.5 and have only noticed it recently.
(sorry
 can't be more precise than that)
 here's the offending class descriptor

 class-descriptor class=com.buyacar.businessobjects.Vehicle
 table=vehicle
blah  blah properties etc
   !-- IMAGES --
collection-descriptor
  name=images
  auto-retrieve=true

element-class-ref=com.buyacar.businessobjects.VehicleImage
  inverse-foreignkey field-id-ref=1/
   /collection-descriptor
 /class-descriptor

 class-descriptor
class=com.buyacar.businessobjects.BACVehicleDetails
 table=bac_details

  reference-descriptor

Re: Limited collection returned

2003-05-31 Thread Jin Bal
I'm also having this problem - thank god someone else's said so !  it's been
driving me mad ;-)

i've been using ojb since 0.9.5 and have only noticed it recently. (sorry
can't be more precise than that)
here's the offending class descriptor

class-descriptor class=com.buyacar.businessobjects.Vehicle
table=vehicle
   blah  blah properties etc
  !-- IMAGES --
   collection-descriptor
 name=images
 auto-retrieve=true
 element-class-ref=com.buyacar.businessobjects.VehicleImage
 inverse-foreignkey field-id-ref=1/
  /collection-descriptor
/class-descriptor

class-descriptor class=com.buyacar.businessobjects.BACVehicleDetails
table=bac_details

 reference-descriptor
name=vehicle
class-ref=com.buyacar.businessobjects.Vehicle
auto-retrieve=true
foreignkey field-id-ref=2/
 /reference-descriptor

/class-descriptor

whenever I load a BACVehicleDetails (and therefore a  Vehicle)  I only ever
get one image in the collection.


more over I have a search engine that only returns 1 result the first time
then 2 on the second submit then 3 ..etc  :-(

heres the search engine code

PersistenceBroker broker = null;
try {
broker = getBroker();
Criteria criteria = new Criteria();

// check if theyve specified a price bracket
if(searchParams.getMaxPrice() !=null 
searchParams.getMinPrice()!=null) {

criteria.addBetween(price,searchParams.getMinPrice(),searchParams.getMaxPr
ice());
} else if(searchParams.getMaxPrice()!=null 
searchParams.getMinPrice()==null) {

criteria.addLessOrEqualThan(price,searchParams.getMaxPrice());
} else if(searchParams.getMaxPrice()==null 
searchParams.getMinPrice()!=null)  {

criteria.addGreaterOrEqualThan(price,searchParams.getMinPrice());
}

if(searchParams.getManufacturer() !=null 
searchParams.getModel()==null) {

criteria.addEqualTo(vehicle.model.manufacturerId,searchParams.getManufactu
rer());
}

if(searchParams.getModel() !=null) {

criteria.addEqualTo(vehicle.modelId,searchParams.getModel());
}
if(searchParams.getBodyStyle() != null) {

criteria.addEqualTo(vehicle.derivative.bodyStyleId,searchParams.getBodySty
le());
}
if(searchParams.getFuelType() != null) {

criteria.addEqualTo(vehicle.derivative.fuelId,searchParams.getFuelType());
}

if(searchParams.getOrderBy() !=null) {
criteria.addOrderByAscending(searchParams.getOrderBy());
}

if(searchParams.getChannel()!=null 
!searchParams.getChannel().equals()) {
criteria.addEqualTo(channel,searchParams.getChannel());
}

criteria.addEqualTo(status,searchParams.getStatus());
criteria.addEqualTo(visibility,searchParams.getVisibility());
criteria.addGreaterOrEqualThan(displayTo,new
java.util.Date());
criteria.addLessOrEqualThan(displayFrom,new java.util.Date());
Query query = new
QueryByCriteria(BACVehicleDetails.class,criteria,true);

Collection c = broker.getCollectionByQuery(query);
logger.debug(collection size: +c.size());
Iterator results = c.iterator();
   ArrayList list = new ArrayList();

while(results.hasNext()) {
// perform cast now to check that we've got the correct
object type
BACVehicleDetails vDetails = (BACVehicleDetails)
results.next();
list.add(vDetails);
}
return list;
} finally {
if (broker!=null) {
broker.close();
}
}

sorry for the long code post


it seems that when the cache is filled up it works ok

help this is stopping me going live with the site  :-(

BTW I did a search on the dev list and noticed a bug opened on the 23rd MAy
but i can't find it now

cheers


Jin

- Original Message -
From: McCaffrey, John G. [EMAIL PROTECTED]
To: 'OJB Users List' [EMAIL PROTECTED]
Sent: Friday, May 30, 2003 5:52 PM
Subject: RE: Limited collection returned


 yes, I also noticed that, and I tried pre-fetching, but that didn't help
me
 either.

 so are you having the same problem then? You are only getting one row
back,
 instead of many?

 (my collection is filled properly with the right child elements, but I am
 not getting all of the parents that match the query, and the query is
select
 all parents)

 can you see the SQL? I couldn't get P6Spy to work, so I don't know what
the
 sql looks like.

 thanks for speaking up, I wonder if anyone else has had/is having this
 problem!

 -John

 -Original Message-
 From: Dan Hanley [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 30, 2003 11:47 AM
 To: OJB Users List
 Subject: RE: Limited collection returned