Re: MS Access Memo Field

2003-11-26 Thread TINO SCHÖLLHORN


Graham Lounder [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 Hey all,Hi,

as I can see you only have to set the data-type in your repository.xml of
the memo-field to LONGVARCHAR.

I have had the same problem, but now it is running fine.

Tino

 I'm trying to save a string greater than 255 characters to a MS Access
memo
 field with no luck.  I'm getting the following error:

 java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]String
data,
 right truncated (null)

 I've done some search on the internet and it seems this is a problem
without
 many solutions.  I did notice that this was suppose to be fixed in rc4.  I
 did read that someone said that it might have something to do with the
 autocommit setting?

 Any Ideas?

 Graham

 
 Graham Lounder - Java Developer
 CARIS Spatial Components Division
 [EMAIL PROTECTED]
 Phone:  (506) 458-8533
 Fax:(506) 459-3849
 
 NO BINDING CONTRACT WILL RESULT FROM THIS EMAIL UNTIL SUCH TIME
 AS A WRITTEN DOCUMENT IS SIGNED ON BEHALF OF THE COMPANY.




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



RE: SQL Exception

2003-11-26 Thread Mahler Thomas
Hi Michael,

The ODMG exceptions do contain the original SQL exceptions to provide user
with helpful information.
I think you could easily patch the RollbackException to wrap the odm
exception.

cu,
Thomas

 -Original Message-
 From: Michael Becke [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 25, 2003 8:35 PM
 To: OJB Users List
 Subject: SQL Exception
 
 
 Hello,
 
 I'm using OJB rc4 with the ODMG api and J2EE transactions.  Currently 
 when a SQL exception occurs on javax.transaction.Transaction 
 commit all 
 I get back is a javax.transaction.RollbackException, which does not 
 contain the original exception.  Is there any way to get 
 access to the 
 original exception that occurs?
 
 Thanks,
 
 Mike
 
 
 -
 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]



Bug in OJB (ODMG) with collections ?

2003-11-26 Thread Philippe Boisaubert
I've got an object which contains a collection. When I change the object collection 
OJB wants to delete the related object in the database. 
For example I've got a Book object with a collection of Author object. I've got an n:m 
non decomposed relationship and my descriptor don't allows cascade-delete cascade 
updates (auto-retrieve=true/auto-delete=false/auto-update=false in my collection 
descriptor).

If I do this :

public void updateBook(Book b, Author newAuthor) {
 tx.begin();
 OQLQuery query = odmg.newOQLQuery();
 query.create(select b from  + Book.class.getName() +  where id =  + b.getId();
 DList results = (DList) query.execute();
 Book myBook = (Book)results.get(0);
 tx.lock(myBook , Transaction.WRITE); 
 myBook.getAuthors().clear();
 myBook.getAuthors().add(newAuthor);
 tx.commit;
}

OJB delete the indirection table's related values and ALSO the author table values.

If I do this :

public void updateBook(Book b, Author newAuthor) {
 tx.begin();
 OQLQuery query = odmg.newOQLQuery();
 query.create(select b from  + Book.class.getName() +  where id =  + b.getId();
 DList results = (DList) query.execute();
 Book myBook = (Book)results.get(0);
 tx.lock(myBook , Transaction.WRITE); 
 ArrayList authList = new ArrayList(); 
 authList.add(newAuthor);
 myBook.setAuthors(authList);
 tx.commit;
}

OJB delete only the indirection table's related values (which is the expected result).

Is it a bug ? Is it a misunderstanding of the framework ?

*
About using/design (related question) :

Generally I want to get a domain (business) object from the persistence layer. Then I 
use it in my app (webapp), modify it and when modification are validated, update it in 
the persistent storage.
I use a class for persistence actions (CRUD) like this :

class BookPersistence {

 static BookPersistence getInstance() {...}
 Book getBook(String bookId) { ...}
 void storeBook(Book b)  { ...}
 void deleteBook(Book b)  { ...}
 void updateBook(Book b)  { ...}
}

And I use it like this :
Book b = new Book();
BookPersistence.getInstance().store(b);
...

And :
Book b1 = BookPersistence.getInstance().getBook(bookID);
b1.setXXX(...);
...
BookPersistence.getInstance().updateBook(b1);

Whith an update method like this :

public void updateBook(Book b) {
 tx.begin();
 tx.lock(myBook , Transaction.WRITE); 
 tx.commit;
}

It doesn work 'cause book is modified outside the transaction and OJB doesn't 
monitor it (I think).
But I can't open a transaction during all the modification time of my object and 
commit at the end, isn't it ?
If I use this object in a webapp (modification by a form), I must wait all the 
validation (and request, validation, ...) before commiting. It retains lock during 
this time (even if I use optimistic locking, a long time transaction can desynchronize 
data with multiple users).
And I've got to add Transaction demarcation in my business process code.

So I try to declare the object dirty in my transaction like this :

public void updateBook(Book b) {
 tx.begin();
 tx.lock(myBook , Transaction.WRITE); 
 ((TransactionImpl)tx).makeDirty(b);
 tx.commit;
}

It generally work but not in the case described above (with a collection) : OJB delete 
related collection object data.
And it's not a standardized process (the makeDirty() of TransactionImpl object is not 
part of ODMG API).

If I do this :

public void updateBook(Book b) {
tx.begin(); 
 OQLQuery query = odmg.newOQLQuery();
 query.create(select b from  + Book.class.getName() +  where id =  + b.getId();
 DList results = (DList) query.execute();
 Book myBook = (Book)results.get(0);
 tx.lock(myBook , Transaction.WRITE);
 
 // I don't think that the following line is usefull 'cause 
 // the OID of Book b is the same than the Book myBook
 // and this object is monitored due to previous query isn't it ?
 BeanUtils.copyProperties(b, myBook);  
 
tx.commit;
}

OJB also delete related collection object data (and : b came from a previous select).

So what's the solution ? Do I use bad patterns ? Is it a bug ? Am I too stupid 
(pleeeaaase tell me I'm not) ?


Thanks.


RE: Bug in OJB (ODMG) with collections ?

2003-11-26 Thread oliver . matz
Hello,

 -Original Message-

 I've got an object which contains a collection. When I change 
 the object collection OJB wants to delete the related object 
 in the database. 

this is one of the most frequently asked questions.
See any of the threads that contain 'RemovalAwareCollection'.

To change the behaviour, add attribute
 
collection-class=
 org.apache.ojb.broker.util.collections.ManageableArrayList

to the respective collection-descriptor.

HTH, Olli

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



Problems with Quickstart

2003-11-26 Thread Stephan Wannenwetsch
Hallo,

I follow the steps descriped on the Quickstart page, but I get the
following error running the command:

bin\build junit

ERROR:
C:\db-ojb-1.0.rc4bin\build junit
Buildfile: build.xml

splash:

set-archive-name:

set-archive-name-date:

detect-jdk:

check-jdk12proxy-classes:

check-jndi-classes:

use-jdk12:

use-jdk13:

use-jdk14:
 [echo] detected JDK 1.4

init:

prepare:
[mkdir] Created dir: C:\db-ojb-1.0.rc4\target
[mkdir] Created dir: C:\db-ojb-1.0.rc4\target\classes
[mkdir] Created dir: C:\db-ojb-1.0.rc4\target\classestest
[mkdir] Created dir: C:\db-ojb-1.0.rc4\target\classesjca
[mkdir] Created dir: C:\db-ojb-1.0.rc4\dist
 [copy] Copied 1 empty directory to C:\db-ojb-1.0.rc4\target\src
 [copy] Copying 24 files to C:\db-ojb-1.0.rc4\target\srctest

BUILD FAILED
file:C:/db-ojb-1.0.rc4/build.xml:143: C:\db-ojb-1.0.rc4\src\jca not
found.

Total time: 18 seconds


I hope someone can help me.

Thanks,

Stephan

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



ClassCastException when accessing a collection using lazy-loading mode

2003-11-26 Thread tristan LEPORS
 Remarque : message transféré en pièce jointe. 

___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com---BeginMessage---
Hi, 

I get sometimes a ClassCastException when I try to get
the children of an object using the lazy-loading mode.
I instist that it is a random error. Most of the
cases, it works very well on exactly the same job.


this is the exception stack trace :

java.lang.ClassCastException:
edu.broglie.ws.dto.AppFlulog
at
edu.broglie.ws.dto.AppAppcli.equals(AppAppcli.java:65)
at
java.util.WeakHashMap$WeakKey.equals(WeakHashMap.java(Compiled
Code))
at java.util.HashMap.put(HashMap.java(Compiled Code))
at java.util.WeakHashMap.put(WeakHashMap.java:298)
at
org.apache.ojb.broker.core.LoadedObjectsRegistry.register(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown
Source)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.loadData(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.ListProxy.loadData(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.getData(Unknown
Source)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.iterator(Unknown
Source)
at
edu.broglie.ws.fwk.ojb.view.ViewFactory.toViewCollection(ViewFactory.java(Compiled
Code))
at
edu.broglie.ws.view.SSACartoView.getListeAC(SSACartoView.java:38)
at java.lang.reflect.Method.invoke(Native Method)
at
edu.broglie.ws.view.parcours.ViewParcours.parcours(ViewParcours.java(Compiled
Code))
at
edu.broglie.ws.view.parcours.ViewParcours.parcoursSelonNomMethode(ViewParcours.java:164)
at
edu.broglie.ws.view.parcours.ViewParcours.parcours(ViewParcours.java:111)
at
edu.broglie.ws.view.parcours.ViewParcours.parcoursSelonNomMethode(ViewParcours.java:164)
at
edu.broglie.ws.view.parcours.ViewParcours.parcours(ViewParcours.java:111)
at
edu.broglie.ws.view.parcours.ViewParcours.parcours(ViewParcours.java:219)
at
edu.broglie.ws.test.TestFonctionCarto.parcoursArbre(TestFonctionCarto.java:93)
at
edu.broglie.ws.test.TestFonctionCarto.testSSACartoView(TestFonctionCarto.java:128)
at
edu.broglie.ws.test.TestFonctionCarto.main(TestFonctionCarto.java:51)


This exception is thrown in the following source code
when getting an iterator from the collection (line 13)
:

/**
 * Method toViewCollection.br
 * Transforme une collection de DTO en collection de
Views.br
 * Utilisé pour les arborescence où il existe
plusieurs composants fils d'un même type.
 * @param dtos
 * @return Collection
 * @throws ViewException
 */
public Collection toViewCollection(Collection dtos)
throws ViewException {
Collection resultat = new ArrayList();
int i=0;
try{
for (Iterator iter = dtos.iterator();
iter.hasNext();) {
i++;
DtoInterface dto = (DtoInterface) iter.next();
resultat.add(toView(dto));

}
}catch(Exception ex){
System.out.println( -- dtos.size() =   +
dtos.size() );
System.out.println( -- i =   + i );

System.out.println( -- toViewCollection() : +
ex.getMessage());
throw new ViewException( probleme interne
surveunu, ex);
}
return resultat;
}




I add part of the repository_user.xml file and some
dto classes. 
I would like get a collection of
edu.broglie.ws.dto.AppAppcli objects instead of
edu.broglie.ws.dto.AppFlulog (witch causes the
classCastException)


Can You help me ?

Tristan.



___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

files.zip
Description: files.zip
---End Message---
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

HOWTO: Calculate primary key inside the insert stored procedure

2003-11-26 Thread Sergey V. Oudaltsov
Hi all

We are trying to insert objects into the table using OJB through some
stored procedure (MS SQL 2000) _without_ specifying the primary key (so
initially it is null). The key is supposed to be calculated inside the
stored procedure. Unfortunately, we get exception assertValidPkFields -
it seems OJB requires us to specify the primary key before actual insert
operation. Is there workaround for this situation? We realize that
probably we are doing some strange thing but still...

I use OJB from CVS.

TIA,

Sergey


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



Re: HOWTO: Calculate primary key inside the insert stored procedure

2003-11-26 Thread Armin Waibel
Hi Sergey,

Did you tried to set field as read-only?
access = read-only
OJB version?
regards,
Armin
Sergey V. Oudaltsov wrote:
Hi all

We are trying to insert objects into the table using OJB through some
stored procedure (MS SQL 2000) _without_ specifying the primary key (so
initially it is null). The key is supposed to be calculated inside the
stored procedure. Unfortunately, we get exception assertValidPkFields -
it seems OJB requires us to specify the primary key before actual insert
operation. Is there workaround for this situation? We realize that
probably we are doing some strange thing but still...
I use OJB from CVS.

TIA,

Sergey

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


PB API: delete then update same object - OptimisticLockException

2003-11-26 Thread oliver . matz
Hello,

I have observed the following:
when I do the following:   

broker.beginTransaction();
broker.delete(x);
broker.store(x, ObjectModificationDefaultImpl.UPDATE);

this fails with a 
org.apache.ojb.broker.KeyConstraintViolatedException

When I use optimistic locking, this fails with
an
 
org.apache.ojb.broker.OptimisticLockException: 
Object has been modified by someone else

I dislike the error message.  Rather than changing the
exception text, I propose the introduce another 
exception ObjectAlreadyDeletedException or the like.

This can easily be implemented using the
Collection field markedForDelete in 
PersistenceBrokerImpl.  Besides, this collection
should be a HashSet rather than an array list.

What do you think?  May I do it?

Should the ObjectAlreadyDeletedException extend
KeyConstraintViolatedException (to preserve at least
some compatibility)?

Alternatively (or additionally), one could introduce
a method  
  PersistenceBroker.isDeleted(Object obj)
and implement that method using
  markedForDelete.contains(obj)


Olli

-- 
  Oliver Matz
  ppi Media GmbH
  Deliusstraße 10
  D-24114 Kiel
  phone +49 (0) 43 1-53 53-422
  fax   +49 (0) 43 1-53 53-2 22
  email mailto:[EMAIL PROTECTED]
  web   www.ppi.de

Explore your printnet!

DRUPA 2004
Düsseldorf, Germany, 6 - 19 May 2004, Booth 6E62

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



RE: ClassCastException

2003-11-26 Thread oliver . matz
Hello,

 -Original Message-

 this is the exception stack trace :
 
 java.lang.ClassCastException:
 edu.broglie.ws.dto.AppFlulog
   at
 edu.broglie.ws.dto.AppAppcli.equals(AppAppcli.java:65)

your implementation of equals() does not fulfil the
contract specified in the javadoc of that method.
It should return false rather than throw a ClassCastException.

63:  public boolean equals(Object other) {
64:boolean egal=true;
65:egal=this.getIdtappcli().equals(((AppAppcli)other).getIdtappcli());
66:return egal;


Olli

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



proxy ClassCastException

2003-11-26 Thread Glauber Andrade
I am trying to use proxy (my first time) and I am getting a
ClassCastException.
What do I need to do? How do I cast ?
Thanks,

Glauber


  Query q = QueryFactory.newQuery(NotaRecibo.class, crit);
  Collection c = broker.getCollectionByQuery(q);
  Iterator iter = c.iterator();
  Object[][] data = new Object[c.size()][17];
  NotaRecibo nota = null;
  while (iter.hasNext()) {
 nota = (NotaRecibo) iter.next();=== ClassCastException
 ...

   class-descriptor
  class=com..data.NotaRecibo
 proxy=dynamic
  table=notasrecibos
   
...

public interface InterfaceNotaRecibo {
...

public class NotaRecibo implements InterfaceNotaRecibo {
...



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



RE: proxy ClassCastException

2003-11-26 Thread Charles Anthony
You must cast to InterfaceNotaRecibo not NotaRecibo.


 -Original Message-
 From: Glauber Andrade [mailto:[EMAIL PROTECTED]
 Sent: 26 November 2003 15:28
 To: [EMAIL PROTECTED]
 Subject: proxy ClassCastException
 Importance: High
 
 
 I am trying to use proxy (my first time) and I am getting a
 ClassCastException.
 What do I need to do? How do I cast ?
 Thanks,
 
 Glauber
 
 
   Query q = QueryFactory.newQuery(NotaRecibo.class, crit);
   Collection c = broker.getCollectionByQuery(q);
   Iterator iter = c.iterator();
   Object[][] data = new Object[c.size()][17];
   NotaRecibo nota = null;
   while (iter.hasNext()) {
  nota = (NotaRecibo) iter.next();=== ClassCastException
  ...
 
class-descriptor
   class=com..data.NotaRecibo
  proxy=dynamic
   table=notasrecibos

 ...
 
 public interface InterfaceNotaRecibo {
 ...
 
 public class NotaRecibo implements InterfaceNotaRecibo {
 ...
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


___
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



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



Changing object properties outside the transaction ...

2003-11-26 Thread Philippe Boisaubert
About using/design with ODMG API :

Generally I want to get a domain (business) object from the persistence layer. Then I 
use it in my app (webapp), modify it and when modification are validated, update it in 
the persistent storage.
I use a class for persistence actions (CRUD) like this :

class BookPersistence {

 static BookPersistence getInstance() {...}
 Book getBook(String bookId) { ...}
 void storeBook(Book b)  { ...}
 void deleteBook(Book b)  { ...}
 void updateBook(Book b)  { ...}
}

And I use it like this :
Book b = new Book();
BookPersistence.getInstance().store(b);
...

And :
Book b1 = BookPersistence.getInstance().getBook(bookID);
b1.setXXX(...);
...
BookPersistence.getInstance().updateBook(b1);

Whith an update method like this :

public void updateBook(Book b) {
 tx.begin();
 tx.lock(myBook , Transaction.WRITE); 
 tx.commit;
}

It doesn work 'cause book is modified outside the transaction and OJB doesn't 
monitor it (I think).

Same things with :

public void updateBook(Book b) {
 tx.begin();
 OQLQuery query = odmg.newOQLQuery();
 query.create(select book from + Book.class.getName()+  where code=\+ 
b.getCode()+ \);
 DList results = (DList) query.execute();
 Book myBook = (Book) results.get(0);
 tx.lock(myBook , Transaction.WRITE);
 tx.commit;
}

But I can't open a transaction during all the modification time of my object and 
commit at the end, isn't it ?
If I use this object in a webapp (modification by a form), I must wait all the 
validation (and request, validation, ...) before commiting. It retains lock during 
this time (even if I use optimistic locking, a long time transaction can desynchronize 
data with multiple users).
And I've got to add Transaction demarcation in my business process code.

So I try to declare the object dirty in my transaction like this :

public void updateBook(Book b) {
 tx.begin(); 
 tx.lock(b, Transaction.WRITE); 
 ((TransactionImpl)tx).makeDirty(b);
 tx.commit;
}

It works but it's not a standardized process (the makeDirty() of TransactionImpl 
object is not part of ODMG API and force db calls even if the object is not modified).

So what's the solution ? Am I obliged to modify the object properties inside the 
transaction ? Do I use bad patterns ? Is there any trick ?

Thanx


Re: HOWTO: Calculate primary key inside the insert stored procedure

2003-11-26 Thread Armin Waibel
sorry i mean
access = readonly
without dash
Armin

Sergey V. Oudaltsov wrote:
Did you tried to set field as read-only?
access = read-only
Not yet. I will though. Right now.


OJB version?
Straight from CVS HEAD (well, yesterday)

Thanks for the idea,



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


Re: Identity

2003-11-26 Thread Armin Waibel
Hi,

assume you are using SequenceManagerNativeImpl?
Please set primarykey=true
Which OJB version?
regards
Armin
Rémi Bars wrote:

Hi all,

i m trying to use identity on sybase with the odmg api. I don t understand
why only one object is insert in my table, when i try to add a second object
i get no error but no record too.
have u an idea?

thanks for ur help!

here is my repository

class-descriptor class='Structure' table='Structure' 
   field-descriptor
name=id
column=id
jdbc-type=numeric
primarykey=true
autoincrement=false
   access=readonly
 /
   field-descriptor name='_Nom' column='nom' jdbc-type='VARCHAR'/
/class-descriptor
here is my table
CREATE TABLE Structure (
id numeric(4,0) identity not null,

nom VARCHAR(50) NULL )

-
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: Changing object properties outside the transaction ...

2003-11-26 Thread Guerrero, Axel
I am doing something very similar to what you are trying to do...
Here's how I addressed the problem:
I have a series of Objects that map to the db tables (I call them data objects).
I also have a series of Objects (i call them view objects, almost exact duplicates of 
the data Objects) that I use to send information back and forth from the data tier to 
the web (form) tier.

Let's say I want to edit a Person object with id 12345.
I do an OJB query with id 12345...
I convert this Person object into a view object so that I can display/modify in a view 
(a jsp page/form).
when I press submit to save the changes, i collect the information from the jsp form 
into a person view and send it to the persistence layer..
the persistence layer then queries OJB for the data object with id 12345. I lock the 
object and copy attributes from the view object into the data object. at the end, I 
close the transaction.

This is the best architecture I could come up with... This may not be *the absolute 
best* but it works for my needs.

Axel Guerrero

-Original Message-
From: Philippe Boisaubert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 10:30 AM
To: [EMAIL PROTECTED]
Subject: Changing object properties outside the transaction ...


About using/design with ODMG API :

Generally I want to get a domain (business) object from the persistence layer. Then I 
use it in my app (webapp), modify it and when modification are validated, update it in 
the persistent storage.
I use a class for persistence actions (CRUD) like this :

class BookPersistence {

 static BookPersistence getInstance() {...}
 Book getBook(String bookId) { ...}
 void storeBook(Book b)  { ...}
 void deleteBook(Book b)  { ...}
 void updateBook(Book b)  { ...}
}

And I use it like this :
Book b = new Book();
BookPersistence.getInstance().store(b);
...

And :
Book b1 = BookPersistence.getInstance().getBook(bookID);
b1.setXXX(...);
...
BookPersistence.getInstance().updateBook(b1);

Whith an update method like this :

public void updateBook(Book b) {
 tx.begin();
 tx.lock(myBook , Transaction.WRITE); 
 tx.commit;
}

It doesn work 'cause book is modified outside the transaction and OJB doesn't 
monitor it (I think).

Same things with :

public void updateBook(Book b) {
 tx.begin();
 OQLQuery query = odmg.newOQLQuery();
 query.create(select book from + Book.class.getName()+  where code=\+ 
b.getCode()+ \);
 DList results = (DList) query.execute();
 Book myBook = (Book) results.get(0);
 tx.lock(myBook , Transaction.WRITE);
 tx.commit;
}

But I can't open a transaction during all the modification time of my object and 
commit at the end, isn't it ?
If I use this object in a webapp (modification by a form), I must wait all the 
validation (and request, validation, ...) before commiting. It retains lock during 
this time (even if I use optimistic locking, a long time transaction can desynchronize 
data with multiple users).
And I've got to add Transaction demarcation in my business process code.

So I try to declare the object dirty in my transaction like this :

public void updateBook(Book b) {
 tx.begin(); 
 tx.lock(b, Transaction.WRITE); 
 ((TransactionImpl)tx).makeDirty(b);
 tx.commit;
}

It works but it's not a standardized process (the makeDirty() of TransactionImpl 
object is not part of ODMG API and force db calls even if the object is not modified).

So what's the solution ? Am I obliged to modify the object properties inside the 
transaction ? Do I use bad patterns ? Is there any trick ?

Thanx

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



Re: Identity

2003-11-26 Thread Armin Waibel
doh! Seems I'm tired or dumb ;-)
I mean autoincrement=true
Or did you implement your owm sequence manager?
abashed,
Armin
Armin Waibel wrote:

Hi,

assume you are using SequenceManagerNativeImpl?
Please set primarykey=true
Which OJB version?
regards
Armin
Rémi Bars wrote:

Hi all,

i m trying to use identity on sybase with the odmg api. I don t 
understand
why only one object is insert in my table, when i try to add a second 
object
i get no error but no record too.

have u an idea?

thanks for ur help!

here is my repository

class-descriptor class='Structure' table='Structure' 
   field-descriptor
name=id
column=id
jdbc-type=numeric
primarykey=true
autoincrement=false
   access=readonly
 /
   field-descriptor name='_Nom' column='nom' 
jdbc-type='VARCHAR'/
/class-descriptor

here is my table
CREATE TABLE Structure (
id numeric(4,0) identity not null,

nom VARCHAR(50) NULL )

-
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: Changing object properties outside the transaction ...

2003-11-26 Thread Philippe Boisaubert
I think about it too. But I must have duplicate object which are the same
(or contains only the updatable properties) than persistent ones.
Another solution will be to use FormBean (I use Struts) but it forces me to
pass a form bean (view data) in my persistent method (persistence layer) as
an argument and copy properties. It works but I don't think it's very clean
for layer separation.
I think about cloning object too. But I never try with this solution.

Thanx for the reply.

- Original Message -
From: Guerrero, Axel [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 6:24 PM
Subject: RE: Changing object properties outside the transaction ...


 I am doing something very similar to what you are trying to do...
 Here's how I addressed the problem:
 I have a series of Objects that map to the db tables (I call them data
objects).
 I also have a series of Objects (i call them view objects, almost exact
duplicates of the data Objects) that I use to send information back and
forth from the data tier to the web (form) tier.

 Let's say I want to edit a Person object with id 12345.
 I do an OJB query with id 12345...
 I convert this Person object into a view object so that I can
display/modify in a view (a jsp page/form).
 when I press submit to save the changes, i collect the information from
the jsp form into a person view and send it to the persistence layer..
 the persistence layer then queries OJB for the data object with id 12345.
I lock the object and copy attributes from the view object into the data
object. at the end, I close the transaction.

 This is the best architecture I could come up with... This may not be *the
absolute best* but it works for my needs.

 Axel Guerrero

 -Original Message-
 From: Philippe Boisaubert [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 26, 2003 10:30 AM
 To: [EMAIL PROTECTED]
 Subject: Changing object properties outside the transaction ...


 About using/design with ODMG API :

 Generally I want to get a domain (business) object from the persistence
layer. Then I use it in my app (webapp), modify it and when modification are
validated, update it in the persistent storage.
 I use a class for persistence actions (CRUD) like this :

 class BookPersistence {

  static BookPersistence getInstance() {...}
  Book getBook(String bookId) { ...}
  void storeBook(Book b)  { ...}
  void deleteBook(Book b)  { ...}
  void updateBook(Book b)  { ...}
 }

 And I use it like this :
 Book b = new Book();
 BookPersistence.getInstance().store(b);
 ...

 And :
 Book b1 = BookPersistence.getInstance().getBook(bookID);
 b1.setXXX(...);
 ...
 BookPersistence.getInstance().updateBook(b1);

 Whith an update method like this :

 public void updateBook(Book b) {
  tx.begin();
  tx.lock(myBook , Transaction.WRITE);
  tx.commit;
 }

 It doesn work 'cause book is modified outside the transaction and OJB
doesn't monitor it (I think).

 Same things with :

 public void updateBook(Book b) {
  tx.begin();
  OQLQuery query = odmg.newOQLQuery();
  query.create(select book from + Book.class.getName()+  where code=\+
b.getCode()+ \);
  DList results = (DList) query.execute();
  Book myBook = (Book) results.get(0);
  tx.lock(myBook , Transaction.WRITE);
  tx.commit;
 }

 But I can't open a transaction during all the modification time of my
object and commit at the end, isn't it ?
 If I use this object in a webapp (modification by a form), I must wait all
the validation (and request, validation, ...) before commiting. It retains
lock during this time (even if I use optimistic locking, a long time
transaction can desynchronize data with multiple users).
 And I've got to add Transaction demarcation in my business process code.

 So I try to declare the object dirty in my transaction like this :

 public void updateBook(Book b) {
  tx.begin();
  tx.lock(b, Transaction.WRITE);
  ((TransactionImpl)tx).makeDirty(b);
  tx.commit;
 }

 It works but it's not a standardized process (the makeDirty() of
TransactionImpl object is not part of ODMG API and force db calls even if
the object is not modified).

 So what's the solution ? Am I obliged to modify the object properties
inside the transaction ? Do I use bad patterns ? Is there any trick ?

 Thanx

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



date issue

2003-11-26 Thread Sng Wee Jim
Hi,

I am using MySQL 4.

When a column of  type date is mapped to JDBC type TIMESTAMP in the 
repository.xml
ie.
   field-descriptor id=2
 name=dateField
 column=dateField
 jdbc-type=TIMESTAMP
 nullable=false
 primarykey=true
   /

writing data to the database via OJB will result in invalid year and 
month being written to database.
For eg. year 2003 will be persisted as 3903(2003+1900)

Changing the jdbc-type to DATE will solve the problem though.

- Jim



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


RE: Changing object properties outside the transaction ...

2003-11-26 Thread Guerrero, Axel
you're correct as far as the duplicate objects goes... if you name your properties the 
same in both objects, you can use BeanUtils (part of the commons jar) to save yourself 
the tedious work of a.setXXX(b.getXXX) when copying properties back and forth.
I'm also using struts so I have to copy the properties from the view object to the 
form bean as well

I am also using EJBs and in my case I could be crossing physical boundries as well as 
logical (EJB servers being in one machine, web servers in another).. so the view 
objects are serializable as well.

Axel

-Original Message-
From: Philippe Boisaubert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 11:41 AM
To: OJB Users List
Subject: Re: Changing object properties outside the transaction ...


I think about it too. But I must have duplicate object which are the same
(or contains only the updatable properties) than persistent ones.
Another solution will be to use FormBean (I use Struts) but it forces me to
pass a form bean (view data) in my persistent method (persistence layer) as
an argument and copy properties. It works but I don't think it's very clean
for layer separation.
I think about cloning object too. But I never try with this solution.

Thanx for the reply.

- Original Message -
From: Guerrero, Axel [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 6:24 PM
Subject: RE: Changing object properties outside the transaction ...


 I am doing something very similar to what you are trying to do...
 Here's how I addressed the problem:
 I have a series of Objects that map to the db tables (I call them data
objects).
 I also have a series of Objects (i call them view objects, almost exact
duplicates of the data Objects) that I use to send information back and
forth from the data tier to the web (form) tier.

 Let's say I want to edit a Person object with id 12345.
 I do an OJB query with id 12345...
 I convert this Person object into a view object so that I can
display/modify in a view (a jsp page/form).
 when I press submit to save the changes, i collect the information from
the jsp form into a person view and send it to the persistence layer..
 the persistence layer then queries OJB for the data object with id 12345.
I lock the object and copy attributes from the view object into the data
object. at the end, I close the transaction.

 This is the best architecture I could come up with... This may not be *the
absolute best* but it works for my needs.

 Axel Guerrero

 -Original Message-
 From: Philippe Boisaubert [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 26, 2003 10:30 AM
 To: [EMAIL PROTECTED]
 Subject: Changing object properties outside the transaction ...


 About using/design with ODMG API :

 Generally I want to get a domain (business) object from the persistence
layer. Then I use it in my app (webapp), modify it and when modification are
validated, update it in the persistent storage.
 I use a class for persistence actions (CRUD) like this :

 class BookPersistence {

  static BookPersistence getInstance() {...}
  Book getBook(String bookId) { ...}
  void storeBook(Book b)  { ...}
  void deleteBook(Book b)  { ...}
  void updateBook(Book b)  { ...}
 }

 And I use it like this :
 Book b = new Book();
 BookPersistence.getInstance().store(b);
 ...

 And :
 Book b1 = BookPersistence.getInstance().getBook(bookID);
 b1.setXXX(...);
 ...
 BookPersistence.getInstance().updateBook(b1);

 Whith an update method like this :

 public void updateBook(Book b) {
  tx.begin();
  tx.lock(myBook , Transaction.WRITE);
  tx.commit;
 }

 It doesn work 'cause book is modified outside the transaction and OJB
doesn't monitor it (I think).

 Same things with :

 public void updateBook(Book b) {
  tx.begin();
  OQLQuery query = odmg.newOQLQuery();
  query.create(select book from + Book.class.getName()+  where code=\+
b.getCode()+ \);
  DList results = (DList) query.execute();
  Book myBook = (Book) results.get(0);
  tx.lock(myBook , Transaction.WRITE);
  tx.commit;
 }

 But I can't open a transaction during all the modification time of my
object and commit at the end, isn't it ?
 If I use this object in a webapp (modification by a form), I must wait all
the validation (and request, validation, ...) before commiting. It retains
lock during this time (even if I use optimistic locking, a long time
transaction can desynchronize data with multiple users).
 And I've got to add Transaction demarcation in my business process code.

 So I try to declare the object dirty in my transaction like this :

 public void updateBook(Book b) {
  tx.begin();
  tx.lock(b, Transaction.WRITE);
  ((TransactionImpl)tx).makeDirty(b);
  tx.commit;
 }

 It works but it's not a standardized process (the makeDirty() of
TransactionImpl object is not part of ODMG API and force db calls even if
the object is not modified).

 So what's the solution ? Am I obliged to modify the object properties
inside the transaction 

Re: prefetch and autoRetreive

2003-11-26 Thread Jakob Braeuchi
hi john,

have you tried disabling the collection-desriptor tweaking in 
RelationshipPrefetcherImpl#prepareRelationshipSettings() ?

public void prepareRelationshipSettings()
{
setCascadeRetrieve(getObjectReferenceDescriptor().getCascadeRetrieve());
getObjectReferenceDescriptor().setCascadeRetrieve(false);  // comment it
}
jakob

John wrote:
I sensed that, but I'm not sure the penalty for loading an object twice is is 
bad as the penalty I was getting.  A lot of places in our code assume the 
object reference is loaded on a required relationship.  One thread was 
prefetching and turned off auto-retrieve, then another came in and thought 
that was the right value and set it back to that.  So from then on none of the 
objects had the relationship loaded and I got NullPointerException everywhere.
 I suppose that multiple loads could be more of an issue with the global 
cache, but with cache-per-broker I'm not sure if that's an issue.  At least to 
me double-load isn't as big a deal as the NPE's.  I had to discontinue using 
prefetch in the couple of places I was using it.  (Not sure that's the worst 
thing anyway, since I don't know that it helped a whole lot.)

John


= Original Message From Jakob Braeuchi [EMAIL PROTECTED] =
hi john,
John wrote:


Has there been any solution to this issue (OJB188)?  This bit me in the 
butt,

but of course it took quite a bit of digging and debugging to realize this 
is

what was happening.  Why exactly is the value changed while prefetching?

auto-retrieve is disabled during prefetching of a relationship to avoid
loading the same obj multiple times.
jakob


I have a patched version of OJB that was based on HEAD from the middle of
August, so I haven't been able to update for a while (don't want to 
repatch).

It seems that there have been some changes to OJB since then with regards 
to

(proxy) prefetching, autoretrieve, etc, especially in how those are 
configured

in the repository.  Are these summarized anywhere?

John Marshall
Connectria
=
Date: Fri, 11 Jul 2003 18:19:33 +0200
From: Jakob Braeuchi [EMAIL PROTECTED]
Subject: Potential problem with prefetch-relationships ?
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
hi theo,

during prefetch auto-retrieve is disabled. when an other thread uses the
relationship-desriptor it will find auto-retrive off.
this is a known problem but i do not have a solution for it :(
jakob

Theo Niemeijer wrote:



Hi all,
I seemed to have stumbled on a potential problem with
the prefetch relationship option in PB query.
After using prefetchRelationship for retrieval of big list of results,
and at the same time performing other queries,
I seemed to have lost the auto-retrieve attribute on
the collection descriptor.
The result was that subsequent queries did not
retrieve that collection anymore, probably because the
auto-retrieve was disabled.
The problem is quite hard to reproduce, but my guess is
that different threads modified the repository descriptor
in the wrong sequence, by means of the setCascadeRetrieve
method used in prepareRelationshipSettings.
I might be wrong, because I simply do not oversee all aspects
of OJB. But am I right to view this as a potential problem
in concurrency situations like websites ?
I do not feel too comfortable that OJB makes these temporary
changes to the repository model.
Cheers,
Theo Niemeijer


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


how to include extra fields in proxy object

2003-11-26 Thread Michael Mogley
Does Ojb offer a way to include additional propertiesin a proxy object besides the id? 
 

I have an Image class with lightweight properties (name and description) and 
heavyweight properties (various versions of the image data itself).  In my webapp, I'd 
like to pull down a list of ImageProxy objects such that getting properties such as 
name and description DOESN'T cause the real subject to be loaded.  I want the real 
subject loaded only when a request for one of the heavy-weight properties is made.

I know I can use ReportQuery to achieve the same result, but then I don't get the 
benefit of the object-cache.

Is there a way to do this in Ojb without having to write my own custom proxy class?

Michael

Re: Changing object properties outside the transaction ...

2003-11-26 Thread Philippe Hacquin
Hi,

using such view objects is a common J2EE pattern (the value object, or 
data transfer object). I use it extensively in Struts and OJB 
applications. It helps decoupling presentation/business 
logic/persistence tiers in your app, and in the case reported by 
Philippe, avoid an adherence to the PersistenceBroker API, when one 
would just tie to the ODMG API.

The drawback is that it adds a lot more classes and code to get and set 
properties in your objects.

So, as usual, the choice between the two alternatives is a matter of 
compromise between efficiency and maintainability/evolutivity.

Guerrero, Axel wrote:
you're correct as far as the duplicate objects goes... if you name your properties the same in 
both objects, you can use BeanUtils (part of the commons jar) to save yourself the tedious work 
of a.setXXX(b.getXXX) when copying properties back and forth.
I'm also using struts so I have to copy the properties from the view object to the 
form bean as well
I am also using EJBs and in my case I could be crossing physical boundries as well as logical (EJB servers being in one machine, web servers in another).. so the view objects are serializable as well.

Axel

-Original Message-
From: Philippe Boisaubert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 11:41 AM
To: OJB Users List
Subject: Re: Changing object properties outside the transaction ...
I think about it too. But I must have duplicate object which are the same
(or contains only the updatable properties) than persistent ones.
Another solution will be to use FormBean (I use Struts) but it forces me to
pass a form bean (view data) in my persistent method (persistence layer) as
an argument and copy properties. It works but I don't think it's very clean
for layer separation.
I think about cloning object too. But I never try with this solution.
Thanx for the reply.



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


Re: Changing object properties outside the transaction ...

2003-11-26 Thread Colin Kilburn
Phillippe,

I wanted to and do the same thing, and I now use this trick:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg04141.html

HTH,
Colin
Philippe Boisaubert wrote:

About using/design with ODMG API :

Generally I want to get a domain (business) object from the persistence layer. Then I 
use it in my app (webapp), modify it and when modification are validated, update it in 
the persistent storage.
I use a class for persistence actions (CRUD) like this :
class BookPersistence {

static BookPersistence getInstance() {...}
Book getBook(String bookId) { ...}
void storeBook(Book b)  { ...}
void deleteBook(Book b)  { ...}
void updateBook(Book b)  { ...}
}
And I use it like this :
Book b = new Book();
BookPersistence.getInstance().store(b);
...
And :
Book b1 = BookPersistence.getInstance().getBook(bookID);
b1.setXXX(...);
...
BookPersistence.getInstance().updateBook(b1);
Whith an update method like this :

public void updateBook(Book b) {
tx.begin();
tx.lock(myBook , Transaction.WRITE); 
tx.commit;
}

It doesn work 'cause book is modified outside the transaction and OJB doesn't monitor it (I think).

Same things with :

public void updateBook(Book b) {
tx.begin();
OQLQuery query = odmg.newOQLQuery();
query.create(select book from + Book.class.getName()+  where code=\+ b.getCode()+ 
\);
DList results = (DList) query.execute();
Book myBook = (Book) results.get(0);
tx.lock(myBook , Transaction.WRITE);
tx.commit;
}
But I can't open a transaction during all the modification time of my object and 
commit at the end, isn't it ?
If I use this object in a webapp (modification by a form), I must wait all the 
validation (and request, validation, ...) before commiting. It retains lock during 
this time (even if I use optimistic locking, a long time transaction can desynchronize 
data with multiple users).
And I've got to add Transaction demarcation in my business process code.
So I try to declare the object dirty in my transaction like this :

public void updateBook(Book b) {
tx.begin(); 
tx.lock(b, Transaction.WRITE); 
((TransactionImpl)tx).makeDirty(b);
tx.commit;
}

It works but it's not a standardized process (the makeDirty() of TransactionImpl object is not part of ODMG API and force db calls even if the object is not modified).

So what's the solution ? Am I obliged to modify the object properties inside the transaction ? Do I use bad patterns ? Is there any trick ?

Thanx

 



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