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]



Repository.xml question

2004-07-30 Thread Noureddine BEKRAR
Hi all;

I want to put by an automatic way the generated idProjectVersion on the 
projectversions table as id of the versions related to the projectVersion.

Is it possible only by changing the repository.xml or should i change the structure of 
the Database?

Thank you in advance.





that is the repository.xml part



class-descriptor class=Project table=project

field-descriptor name=id primarykey=true nullable=false default-fetch=true 
autoincrement=true 

column=id sequence-name=project_id_seq jdbc-type=INTEGER/

field-descriptor name=name column=name jdbc-type=VARCHAR/

field-descriptor name=idClient column=idClient jdbc-type=INTEGER/

field-descriptor name=type column=type jdbc-type=VARCHAR/

field-descriptor name=status column=status jdbc-type=VARCHAR/ 

collection-descriptor

name=versionsList

collection-class=org.apache.ojb.broker.util.collections.RemovalAwareCollection

element-class-ref=ProjectVersion

auto-update=true auto-delete=true

inverse-foreignkey field-ref=idProject/

/collection-descriptor

/class-descriptor



/class-descriptor

class-descriptor class=ProjectVersion table=projectversions

field-descriptor name=idProjectVersion primarykey=true nullable=false 
default-fetch=true autoincrement=true 

column=idProjectVersion sequence-name=version_id_seq jdbc-type=INTEGER/

field-descriptor name=idProject column=idProject jdbc-type=INTEGER /

field-descriptor name=current column=current jdbc-type=VARCHAR / 

collection-descriptor

name=versionsList

collection-class=org.apache.ojb.broker.util.collections.RemovalAwareCollection

element-class-ref=Version

auto-update=true auto-delete=false

inverse-foreignkey field-ref=id/

/collection-descriptor

/class-descriptor

class-descriptor class=Version table=projectversiondesc

field-descriptor name=id column=id jdbc-type=INTEGER primarykey=true/

field-descriptor name=lang column=lang jdbc-type=VARCHAR primarykey=true/ 

field-descriptor name=description column=description jdbc-type=VARCHAR /

field-descriptor name=status column=status jdbc-type=VARCHAR / 

/class-descriptor



that is tables

 
CREATE TABLE projectversions (
  idProjectVersion int(10) NOT NULL auto_increment,
  idProject int(10) NOT NULL default '0',
  current enum('Y','N') NOT NULL default 'N',
  PRIMARY KEY  (idProjectVersion,idProject)
) TYPE=MyISAM;

 
CREATE TABLE `projectversiondesc` (
  `id` int(10) NOT NULL default '0',
  `lang` enum('fr','en') NOT NULL default 'fr',
  `description` varchar(30) NOT NULL default '',
  `status` enum('A','I') NOT NULL default 'A',
  PRIMARY KEY  (`id`,`lang`)
) TYPE=MyISAM;

Re: Repository.xml question

2004-07-30 Thread Noureddine BEKRAR
I want  to give more information about  my problem:
when i create a new ProjectVersion , i put in it a Version, the id of the
ProjectVersion is right but the id of the version is 0, how can i do to put
by an automatic way the id of the ProjectVersion  in the Version.



- Original Message - 
From: Noureddine BEKRAR [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 30, 2004 12:06 PM
Subject: Repository.xml question


Hi all;

I want to put by an automatic way the generated idProjectVersion on the
projectversions table as id of the versions related to the projectVersion.

Is it possible only by changing the repository.xml or should i change the
structure of the Database?

Thank you in advance.





that is the repository.xml part



class-descriptor class=Project table=project

field-descriptor name=id primarykey=true nullable=false
default-fetch=true autoincrement=true

column=id sequence-name=project_id_seq jdbc-type=INTEGER/

field-descriptor name=name column=name jdbc-type=VARCHAR/

field-descriptor name=idClient column=idClient jdbc-type=INTEGER/

field-descriptor name=type column=type jdbc-type=VARCHAR/

field-descriptor name=status column=status jdbc-type=VARCHAR/

collection-descriptor

name=versionsList

collection-class=org.apache.ojb.broker.util.collections.RemovalAwareCollect
ion

element-class-ref=ProjectVersion

auto-update=true auto-delete=true

inverse-foreignkey field-ref=idProject/

/collection-descriptor

/class-descriptor



/class-descriptor

class-descriptor class=ProjectVersion table=projectversions

field-descriptor name=idProjectVersion primarykey=true nullable=false
default-fetch=true autoincrement=true

column=idProjectVersion sequence-name=version_id_seq
jdbc-type=INTEGER/

field-descriptor name=idProject column=idProject jdbc-type=INTEGER /

field-descriptor name=current column=current jdbc-type=VARCHAR /

collection-descriptor

name=versionsList

collection-class=org.apache.ojb.broker.util.collections.RemovalAwareCollect
ion

element-class-ref=Version

auto-update=true auto-delete=false

inverse-foreignkey field-ref=id/

/collection-descriptor

/class-descriptor

class-descriptor class=Version table=projectversiondesc

field-descriptor name=id column=id jdbc-type=INTEGER
primarykey=true/

field-descriptor name=lang column=lang jdbc-type=VARCHAR
primarykey=true/

field-descriptor name=description column=description
jdbc-type=VARCHAR /

field-descriptor name=status column=status jdbc-type=VARCHAR /

/class-descriptor



that is tables


CREATE TABLE projectversions (
  idProjectVersion int(10) NOT NULL auto_increment,
  idProject int(10) NOT NULL default '0',
  current enum('Y','N') NOT NULL default 'N',
  PRIMARY KEY  (idProjectVersion,idProject)
) TYPE=MyISAM;


CREATE TABLE `projectversiondesc` (
  `id` int(10) NOT NULL default '0',
  `lang` enum('fr','en') NOT NULL default 'fr',
  `description` varchar(30) NOT NULL default '',
  `status` enum('A','I') NOT NULL default 'A',
  PRIMARY KEY  (`id`,`lang`)
) TYPE=MyISAM;


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



addOrderBy

2004-07-30 Thread Glauber Andrade






Hello,

I was using rc5 andI changed to 1.0.0 today.
I use Criteria.addOrderBy() and now it has been deprecated. How do I order ??

Glauber









 IncrediMail - O mundo do correio eletrônico finalmente desenvolveu-se - Clique aqui

Re: addOrderBy

2004-07-30 Thread Edson Carlos Ericksson Richter
I think you should create a QueryByCriteria, and the use the addOrderBy
on the query.

Richter

Em Sex, 2004-07-30 às 11:19, Glauber Andrade escreveu:
 Hello,
  
 I was using rc5 and I changed to 1.0.0 today.
 
 I use Criteria.addOrderBy() and now it has been deprecated. How do I
 order ??
  
 Glauber
  
  
 
 
 
 
   IncrediMail - O mundo do correio eletrônico finalmente
 desenvolveu-se - Clique aqui


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



Res: Re: addOrderBy

2004-07-30 Thread Glauber Andrade






I don´t understand...
What should I do ?

Criteria crit = new Criteria();crit.addEqualTo("nf", nf);// crit.addOrderBy("company.type", true); // deprecated
Query query = new QueryByCriteria(Note.class, crit);

---Mensagem original---


De: OJB Users List
Data: 07/30/04 11:22:49
Para: OJB Users List
Assunto: Re: addOrderBy

I think you should create a QueryByCriteria, and the use the addOrderBy
on the query.

Richter

Em Sex, 2004-07-30 às 11:19, Glauber Andrade escreveu:
 Hello,

 I was using rc5 and I changed to 1.0.0 today.

 I use Criteria.addOrderBy() and now it has been deprecated. How do I
 order ??

 Glauber





 
 IncrediMail - O mundo do correio eletrônico finalmente
 desenvolveu-se - Clique aqui


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








 IncrediMail - O mundo do correio eletrônico finalmente desenvolveu-se - Clique aqui

Re: Res: Re: addOrderBy

2004-07-30 Thread Gerhard Hipfinger
hi,

just do this

sample
QueryByCriteria query = new QueryByCriteria(Note.class, crit);
query.addOrderBy(company.type, true);
/sample

the orderBy methods where moved to the QueryByCriteria class.

gerhard

Am Fre, den 30.07.2004 schrieb Glauber Andrade um 16:45:
 I don´t understand...
 What should I do ?
  
 Criteria crit = new Criteria();
 crit.addEqualTo(nf,  nf);
 // crit.addOrderBy(company.type, true);// deprecated
 Query query = new QueryByCriteria(Note.class, crit);
 
  
 ---Mensagem original---
  
 De: OJB Users List
 Data: 07/30/04 11:22:49
 Para: OJB Users List
 Assunto: Re: addOrderBy
  
 I think you should create a QueryByCriteria, and the use the
 addOrderBy
 on the query.
  
 Richter
  
 Em Sex, 2004-07-30 às 11:19, Glauber Andrade escreveu:
  Hello,
 
  I was using rc5 and I changed to 1.0.0 today.
 
  I use Criteria.addOrderBy() and now it has been deprecated. How do I
  order ??
 
  Glauber
 
 
 
 
 
  
IncrediMail - O mundo do correio eletrônico finalmente
  desenvolveu-se - Clique aqui
  
  
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
  
 
 
 
 
   IncrediMail - O mundo do correio eletrônico finalmente
 desenvolveu-se - Clique aqui


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



Re: Res: Re: addOrderBy

2004-07-30 Thread Edson Carlos Ericksson Richter
I use

Criteria crit = new Criteria();
crit.addEqualTo(nf, nf);
QueryByCriteria q = new QueryByCriteria(Note.class, crit);
q.addOrderByAscending(company.type);


Richter


Em Sex, 2004-07-30 às 11:45, Glauber Andrade escreveu:
 I don´t understand...
 What should I do ?
  
 Criteria crit = new Criteria();
 crit.addEqualTo(nf,  nf);
 // crit.addOrderBy(company.type, true);// deprecated
 Query query = new QueryByCriteria(Note.class, crit);
 
  
 ---Mensagem original---
  
 De: OJB Users List
 Data: 07/30/04 11:22:49
 Para: OJB Users List
 Assunto: Re: addOrderBy
  
 I think you should create a QueryByCriteria, and the use the
 addOrderBy
 on the query.
  
 Richter
  
 Em Sex, 2004-07-30 às 11:19, Glauber Andrade escreveu:
  Hello,
 
  I was using rc5 and I changed to 1.0.0 today.
 
  I use Criteria.addOrderBy() and now it has been deprecated. How do I
  order ??
 
  Glauber
 
 
 
 
 
  
IncrediMail - O mundo do correio eletrônico finalmente
  desenvolveu-se - Clique aqui
  
  
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
  
 
 
 
 
   IncrediMail - O mundo do correio eletrônico finalmente
 desenvolveu-se - Clique aqui


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



Looks like TransactionImpl.abort is not called when a SQLException is thrown from ConnectionManagerImpl.localCommit

2004-07-30 Thread Mark Neighbors
It looks like TransactionImpl.abort is not called when a SQLException is thrown
from ConnectionManagerImpl.localCommit

The call sequence is

   * org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localCommit
   * org.apache.ojb.broker.core.PersistenceBrokerImpl.commitTransaction
   * org.apache.ojb.odmg.TransactionImpl.commit

The jdbc commit is performed in ConnectionManagerImpl.localCommit.

If a SQLException is thrown from the jdbc driver then

(1) localCommit has an exception handler for SQLException.  The SQLException is
wrapped in a org.apache.ojb.broker.TransactionAbortedException and then the
TransactionAbortedException is thrown back to PersistenceBrokerImpl.
commitTransaction.

(2) PersistenceBrokerImpl.commitTransaction implicitly rethrows the org.apache.
ojb.broker.TransactionAbortedException back to TransactionImpl.commit.

(3) But there isn't an exception handler for org.apache.ojb.broker.
TransactionAbortedException and so TransactionImpl.commit implicitly
rethrows the exception back to the application.

TransactionImpl.commit has an exception handler for org.odmg.
ODMGRuntimeException.  TransactionImpl.abort is called from this exception
handler.

org.apache.ojb.odmg.TransactionAbortedExceptionOJB extends org.odmg.
ODMGRuntimeException, but org.apache.ojb.broker.TransactionAbortedException
does not.  This seems to be the problem.

I temporarily added the following exception handler to TransactionImpl.commit
and TransactionImpl.abort was called.

   catch (org.apache.ojb.broker.TransactionAbortedException ex)
   {
  m_txStatus = Status.STATUS_MARKED_ROLLBACK;
  if (log.isDebugEnabled()) log.debug(Commit fails, do abort this tx, ex);
  abort();
  handleOJBTransactionAbortedException(ex) ;
   }

where

   private void handleOJBTransactionAbortedException(
   org.apache.ojb.broker.TransactionAbortedException e)
  throws org.odmg.TransactionAbortedException
   {
  if (e.getCause() != null)
  {
 throw new org.apache.ojb.odmg.TransactionAbortedExceptionOJB(
  e.getCause()) ;
  }
  else
  {
 throw new org.apache.ojb.odmg.TransactionAbortedExceptionOJB(e) ;
  }
   }

I also made similar patches in other TransactionImpl methods.  The patched
TransactionImpl class is included.  The patched class is at rc6 since we are
currently at rc6, but the source for 1.0 seems the same here.

Thanks in advance,
Mark

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

afterCommit is being called before the actual sql commit in ConnectionManagerImpl.localCommit. Is this the intent?

2004-07-30 Thread Mark Neighbors
afterCommit is being called before the actual sql commit in ConnectionManagerImpl.
localCommit.  Is this the intent?

TransactionImpl.commit calls
   * TransactionImpl.prepare indirectly calls
* beforeCommit
* beforeUpdate (or Insert, or Delete)
* sql update, or insert, or delete
* afterUpdate (or Insert, or Delete)
* afterCommit
   * PersistenceBrokerImpl.commitTransaction calls
* ConnectionManagerImpl.localCommit calls
 * sql commit

This would have to be resequenced slightly to get afterCommit called after the
sql commit.

The reason why I'm asking is that we are storing blob data outside the database.
We are using the after callbacks to implement rollback for these.

The ojb-maintained persistent field is a relative pathname to the binary file.
The blob is a transient field in the persistent class.  A persistent timestamp
field ensures update if the blob is modified and no other field is.  

The basic approach to rollback here is 

   * afterInsert
* write the transient field to file
* state = afterInsert

   * afterUpdate
* copy file to file.rollback
* write the transient field to file
* state = afterUpdate

   * afterDelete
* rename file to file.deleted
* delete file.rollback
* state = afterDelete

   * afterAbort
* state == afterInsert
 * delete file
* state == afterUpdate
 * rename file.rollback to file
* state == afterDelete
 * rename file.deleted to file
* finally
 * transient field = null
 * state = null

   * afterLookup
* transient field == null
 * read file into transient field

All the callbacks are synchronized.
  
The case of delete is slightly different than update.  If the sql commit occurred
before the afterCommit was called then afterCommit could delete the save copy.
Otherwise an occasional sweep is needed to remove all the .deleted files.


The state keeping mentioned above is done by the after callbacks only so 
hopefully this will work with optimistic locking.  It appears that optimistic
locking LockNotGrantedExceptions are thrown at the point of sql update/delete.

   * Depending on the cache could there be concurrent updating/deleting threads
 in the object up to this point?  It seems so.

   * What about concurrent reading threads?  It appears as though reading
 threads only execute afterLookup/beforeCommit/afterCommit.  But it looks
 like afterAbort could be called in a reading thread and so could trigger
 the actions mentioned above.  Maybe keeping the insert/update/delete
 state in a ThreadLocal could keep this from happening.

   * We are currently using the odmg layer, and plan to cluster our application
 in the future.

   The ojb docs currently state

  4.29. How to use OJB in a cluster
  ...

  transactional isolation and locking 
  
  If you are using the PersistenceBroker API use optimistic locking (OL)
  ...

  If you are working with the ODMG API distributed pessimistic locking
  should be used, by setting the respective flag in OJB.properties. 
  
   Are there plans to support optimistic locking in the odmg layer in a
   clustered configuration?

   Is optimistic locking currently supported by the odmg layer in a
   non-clustered configuration?

Thanks in advance,
Mark


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



Re: Found unclosed resources while finalize

2004-07-30 Thread Jakob Braeuchi
hi zhe,
the RsIterator is closed when it has no more elements or when releaseDbResources 
 is called. in case the RsIterator is still open, it get's closed during finalize.

hth
jakob
ZZZ Liu schrieb:
Hi,
I am using OJB 1.0.
I found following message appeared a lot of times in 
my log file. Could anybody tell me what does that mean
and what would cause that problem?

29 Jul 2004 20:27:43 5408  INFO  [Finalizer]
accesslayer.ReportQueryRsIterator - Found unclosed
resources while finalize (causer class:
org.apache.ojb.broker.accesslayer.ReportQueryRsIterator)
Do automatic cleanup
Thanks in advance,
Zhe

		
__
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 

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


Another piece of the puzzle? (was Re: Negative Sequence Numbers?)

2004-07-30 Thread Robert Crawford
I double-checked the configuration of my tests and realized I was running
tests on a subclass, not the original User class that gets the wrong
sequence numbers.

So I dropped back and ran just the superclass. Everything worked fine; the
sequence numbers were assigned correctly. So the configuration's OK for
that class.

Then I ran the tests again with the subclass. This class extends the
original User class, with the extended information stored on a separate
table, joined by the primary key. The second table's reference-descriptor
is this:

reference-descriptor name=super
class-ref=com.kloognome.accesscontrol.ojb.UserInstance
auto-retrieve=true
auto-update=true
auto-delete=true

foreignkey field-ref=userNbr/
/reference-descriptor

This time the key's messed up.

It looks like the problem's related to the super-class relationship. Any
ideas? I'm going to try the idea of having different primary keys on each
table, with the subclass table referring to the superclass table in one of
its columns. I don't know why this would work any better, but...


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