Re: setStartAtIndex and setEndAtIndex

2003-07-31 Thread Mykola Ostapchuk
Works fine for me, I'm using rc4 and MSSQL with microsoft jdbc driver too.

Here's code I'm using:

Collection results = null;
query.setStartAtIndex(offset);
query.setEndAtIndex(offset+recordsPerPage);
results = (Collection) broker.getCollectionByQuery(query);


Regards,
Mykola


- Original Message - 
From: "Gelhar, Wallace Joseph" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 11:11 AM
Subject: setStartAtIndex and setEndAtIndex


>Hi,

>I'm trying to implement paging using setStartAtIndex and setEndAtIndex
>using RC4 against MSSQL with the microsoft jdbc driver.  The query is
>still returning a full resultset regardless of what I set.   Has anyone
>gotten this to work using this combination?

>Wally

-
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: Confused about SequenceManager and MSSQL's uniqueidentifier

2003-07-30 Thread Mykola Ostapchuk
As far as I understand, MSSQL doesn't have any sequence managers (Oracle,
SAP DB, PostgreSQL have).
Identity field type isn't the same as sequence manager.
If I'm wrong, please, correct me.

Regards,
Mykola


- Original Message - 
From: "Andrew Clute" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, July 30, 2003 10:45 AM
Subject: Confused about SequenceManager and MSSQL's uniqueidentifier


> We have an existing database that uses GUID's as it's primary key for
across
> all tables. The PK's are defined as uniqueidentifier types, and their
> default value is 'newid()' -- which is a call to generate a new GUID for
> that ID.
>
> My goal is to continue to use this pattern for generation of sequence
> numbers for our implementation of OJB. And if I read it right, that means
I
> want to use the 'database generated sequences' concept in OJB, with the
> SequenceManagerNextValImpl Sequence Manager.
>
> Now, on this page here
> (http://db.apache.org/ojb/howto-use-db-sequences.html), it talks about
> needing to name your database sequences when you create your table (in the
> example it is 'UniqueIdentifier') and that name is then used as the
> attribute 'sequence-name' for the field-descriptor. But in our situation,
> there is really no Sequence defined, with a name associated it, we are
> really just using the default value that the table has associated with it.
>
> So, how would I go about merging the concepts together? Can I use the
> SequenceManagerNextValImpl and not give the  sequence-name attribute for
my
> PK field-descriptor -- will it just default then to the value genrated by
> the database?
>
> Thanks in advance!
> -Andrew
>
>
> -
> 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: creating persistence broker

2003-07-28 Thread Mykola Ostapchuk
You can try instantiate broker this way:

PBKey pbKey = new PBKey("default");
broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);

where "default" - jcd-alias property value in jdbc-connection-descriptor.


Regards,
Mykola Ostapchuk



- Original Message - 
From: "Durham David Contr 805 CSS/SCBE" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 28, 2003 3:14 PM
Subject: creating persistence broker


Hi all,

This is a newbie question.

I'm trying to execute the following code:
broker = PersistenceBrokerFactory.defaultPersistenceBroker();


I receive the following error:

java.lang.NoClassDefFoundError
at
org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(
Unknown Source)


Have the following in OJB.properties file:

PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImpl


Any ideas what would cause 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: Database sequences based implementation problem

2003-07-21 Thread Mykola Ostapchuk
Hi Armin,

Does it means I can't use SequenceManagerNextValImp with SQL Server 2000
too?


Regards,
Mykola



> MySQL does not support database based key generation
> (MySQL supports only Identity columns).
> You have to use another sequence manager implementation.
> http://db.apache.org/ojb/sequencemanager.html
>
> regards,
> Armin
>
> - Original Message -
> From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, July 19, 2003 1:05 AM
> Subject: Database sequences based implementation problem
>
>
> > Hello,
> >
> > I'm trying to use Database sequences based implementation and receive
> an
> > exception below.
> > I'm using MySql. Primary field "ST_id" has "Autoincrement" option
> checked.
> >
> > repository.xml:
> >
> > Sequence Manager:
> >
> >  >
> className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImp
> l">
> > 
> > 
> >
> > Primary field:
> >  jdbc-type="BIGINT"
> > primarykey="true" autoincrement="true"/>
> >
> >
> > Exception:
> >
> >
> > : org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> Could
> > not init Identity for given object
> >  class com.iprs.core.countries.StatesVO: Could not get key value:
> > Could not grab next id, failed with
> > This feature is not supported by this implementation
> > Creation of new sequence failed with
> > This feature is not supported by this implementation
> > : This feature is not supported by this implementation
> > An exception has been caused by:
> > java.lang.UnsupportedOperationException: This feature is not supported
> by
> > this implementation
> > at
> >
> org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
> Unkn
> > own Source)
> > at
> >
> org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
> uenc
> > e(Unknown Source)
> > at
> >
> org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
> Long
> > (Unknown Source)
> > at
> >
> org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueVal
> ue(U
> > nknown Source)
> >
> >
> > Any suggestions what's wrong?
> >
> >
> > Regards,
> > Mykola
> >
> >
> > -
> > 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]



Database sequences based implementation problem

2003-07-18 Thread Mykola Ostapchuk
Hello,

I'm trying to use Database sequences based implementation and receive an
exception below.
I'm using MySql. Primary field "ST_id" has "Autoincrement" option checked.

repository.xml:

Sequence Manager:





Primary field:



Exception:


: org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Could
not init Identity for given object
 class com.iprs.core.countries.StatesVO: Could not get key value:
Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
An exception has been caused by:
java.lang.UnsupportedOperationException: This feature is not supported by
this implementation
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(Unkn
own Source)
at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSequenc
e(Unknown Source)
at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUniqueLong
(Unknown Source)
at
org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueValue(U
nknown Source)


Any suggestions what's wrong?


Regards,
Mykola


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



M:N problem

2003-07-14 Thread Mykola Ostapchuk
Hi,
I'm having a problem with m:n relationship.

DB tables:
users  <- usersroles -> roles

usersroles table contains foreign keys to users table (UR_US_id_FK) and to
roles table (UR_RL_id_FK).

repository_user.xml:


 
 


  


---If I comment this reference, everything works fine

  








 

 
 


 
 

 



UsersRolesVO class:

public class UsersRolesVO extends ValueObject {
private Long urUSIdFK;
private Long urRLIdFK;
private RolesVO urRoles;
private UsersVO urUsers;

get()/set() ommitted.
}




20531 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?
20531 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
US_f_name,US_password,US_active,US_id,US_CO_id_FK,US_date_inserted,US_zip,US
_ST_id_FK,US_l_name,US_username,US_email,US_city,US_address FROM users WHERE
US_id = ?
20547 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?
20547 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?
20563 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?
20578 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?


20578 DEBUG [Thread-5] sql.SqlGeneratorDefaultImpl - SQL:SELECT
A0.UR_US_id_FK,A0.UR_RL_id_FK FROM usersroles A0 WHERE A0.UR_US_id_FK =  ?



I receive an infinite loop (see SQL:SELECT A0.UR_US_id_FK,A0.UR_RL_id_FK
FROM usersroles A0 WHERE A0.UR_US_id_FK =  ? ) and Tomcat shuts down.

Does anybody knows where the problem is? I believe I'm setting m:n
relationship according to example in OJB doc.

Thanks a lot!
Mykola Ostapchuk


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



Re: how select count(*)

2003-07-10 Thread Mykola Ostapchuk
Use getCount(query) method:

int recordsCount = broker.getCount(query);

Regards,
Mykola


- Original Message - 
From: "Lopez Vellon, Ignacio" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 10, 2003 11:44 AM
Subject: how select count(*)


Does anyone know how to perform select count(*) against a table in my
database using OJB?

-
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: DateTime conversion problem again

2003-07-09 Thread Mykola Ostapchuk
Hi Edson,

After migration to OJB 1.0.rc3 I don't have this problem anymore.
Can anybody confirm it was a bug in OJB 0.9.7?

Regards,
Mykola Ostapchuk



> What your GMT? In my case, all date/time are stored in database with -3
> hours, because I'm on GMT-3. I'm using SapDB.
> I think that is this you getting, and it's a internationalization Java
> feature...
> Can someone else confirm this?
>
> Edson Richter
>
>
> - Original Message - 
> From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 08, 2003 9:23 PM
> Subject: DateTime conversion problem again
>
>
> Sorry to post this question again, I still can't solve the problem. Any
help
> will be very appreciated!
>
>
> Can anybody tell me how to map DateTime MySql field in OJB?
>
>
> My realization is the next:
>
>  jdbc-type="TIMESTAMP"
>
>
conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimest
> ampFieldConversion"/>
>
> userDateInserted - of type java.util.Date.
>
> After setting the Date, OJB inserts right date. But time is 1 hour minus
of
> the actual time (minutes and seconds are right).
> Interesting, the userDateInserted has right Date value, but after passing
it
> thru OJB, Date is decreased for 1 hour...
> Is it some kind of a bug?
> Am I doing something wrong?
> Any suggestions?
>
>
> Regards,
> Mykola Ostapchuk
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.497 / Virus Database: 296 - Release Date: 4/7/2003
>


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



Re: Can't instantiate query

2003-07-09 Thread Mykola Ostapchuk
I solved the problem by using
Query query = new QueryByCriteria(CountriesVO.class, criteria);

I'm wandering why
Query query = QueryFactory.newQuery(CountriesVO.class,criteria);
doesn't work in OJB 1.0.rc3?..

Regards,
Mykola

- Original Message - 
From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 1:22 PM
Subject: Can't instantiate query


> Hi,
>
> I can't instantiate query with the next line:
> Query query = QueryFactory.newQuery(CountriesVO.class, criteria);
> It generates error and method returns null.
> The method worked well with OJB 0.9.7, now I'm using OJB 1.0.rc3.
> Does anybody have any idea what can be wrong?
>
> One more question: I don't understand why catch (Exception e)  doesn't
> actually cach an Exception?
> I've System.out and log.error in catch statement - none of them prints
> nothing.
>
> Here's my method:
>
>
> public Vector allCountries() throws DataAccessException {
> log.info("Entering the
> CountriesDAO.allCountries()***");
> PersistenceBroker broker = null;
> Vector results = null;
> try{
> Criteria criteria = new Criteria();
> criteria.addOrderBy("CO_name");
> Query query = QueryFactory.newQuery(CountriesVO.class,
> criteria);
> query.setStartAtIndex(1);
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> results = (Vector) broker.getCollectionByQuery(query);
> }
> catch (Exception e) {
> System.out.println("Error: "+e.toString());
> log.error("Exception thrown in CountriesDAO.allCountries(): "
+
> e.toString());
> }
> finally {
> if (broker != null) broker.close();
> }
> log.info("Done with
> CountriesDAO.allCountries()***");
> return results;
> }
>
>
>
> Please, help!
>
> Regards,
> Mykola
>
>
> -
> 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]



Can't instantiate query

2003-07-09 Thread Mykola Ostapchuk
Hi,

I can't instantiate query with the next line:
Query query = QueryFactory.newQuery(CountriesVO.class, criteria);
It generates error and method returns null.
The method worked well with OJB 0.9.7, now I'm using OJB 1.0.rc3.
Does anybody have any idea what can be wrong?

One more question: I don't understand why catch (Exception e)  doesn't
actually cach an Exception?
I've System.out and log.error in catch statement - none of them prints
nothing.

Here's my method:


public Vector allCountries() throws DataAccessException {
log.info("Entering the
CountriesDAO.allCountries()***");
PersistenceBroker broker = null;
Vector results = null;
try{
Criteria criteria = new Criteria();
criteria.addOrderBy("CO_name");
Query query = QueryFactory.newQuery(CountriesVO.class,
criteria);
query.setStartAtIndex(1);
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
results = (Vector) broker.getCollectionByQuery(query);
}
catch (Exception e) {
System.out.println("Error: "+e.toString());
log.error("Exception thrown in CountriesDAO.allCountries(): " +
e.toString());
}
finally {
if (broker != null) broker.close();
}
log.info("Done with
CountriesDAO.allCountries()***");
return results;
}



Please, help!

Regards,
Mykola


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



Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3

2003-07-09 Thread Mykola Ostapchuk
I've tried e.printStackTrace() , log.error, simple System.out - none of them
prints anything.
I've configured log4j.properties to DEBUG everything - the same result.

I found the problem - jcd-alias="default" was missing in repository.xml.
OJB 0.9.7 doesn't require it, but OJB 1.0.rc3 does.


Regards,
Mykola


- Original Message - 
From: "Edson Carlos Ericksson Richter" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; "Mykola Ostapchuk"
<[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 6:36 AM
Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3


> Can you try to change from log.error to e.printStackTrace() so we can have
> more info about line/stack trace?
>
> The code you are using to obtain the broker is exatly same I'm using, so
> it's right.
>
> What about .xml and .dtd? You remembered to updated too?
>
> Edson
>
> - Original Message - 
> From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 08, 2003 9:14 PM
> Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3
>
>
> Hello,
>
> I've spent 2 days trying to migrate my application from OJB 0.9.7 to OJB
> 1.0.rc3, and still no success.
> The problem is - I can't instantiate broker with the next line:
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>
> I'm using default OJB.properties from 1.0 rc3. I have db-ojb-1.0.rc3.jar
and
> all additional *.jar files in /lib folder.
> I debug RepositoryXmlHandler and it seems there're no problems (see code
> snap from pevious message below).
>
> Line:
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> generates some error I don't know how to cach.
> log.error in cach statement doesn't print anything.
>
>
> try {
>   broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>   usersVO.setUsername(username);
>   usersVO.setPassword(password);
>   Query query = new QueryByCriteria(usersVO);
>   usersVO = (UsersVO) broker.getObjectByQuery(query);
> } catch (Exception e) {
>   log.error("PersistenceBrokerException thrown in UsersDAO.findByUP():
"
> + e.toString());
> }
>
>
> With OJB 0.9.7 everything works fine.
> I'll very appreciate any help!
>
>
> Regards,
> Mykola Ostapchuk
>
>
>
>
>
>
> - Original Message - 
> From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, July 08, 2003 11:52 AM
> Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3
>
>
> > Sorry for the previous message. Here's the log:
> >
> >
> > 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - startDoc
> > 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler -  >
> > descriptor-repository
> > 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - <
documentation
> > 15DEBUG [Thread-5] metadata.RepositoryXmlHandler -   >
> class-descriptor
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
> isolation-level:
> > read-uncommitted
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  class:
> > com.iprs.web.users.UsersVO
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  proxy: null
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  table: users
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  row-reader:
> null
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  extends:
null
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
accept-locks:
> > true
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
accept-locks:
> > true
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
> > initialization-method: null
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  refresh:
true
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
> > field-descriptor
> > 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name: userId

> > 46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column:
US_id
> > 46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
> > BIGINT
>

> 
>

> ....
> > > [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: endD

DateTime conversion problem again

2003-07-08 Thread Mykola Ostapchuk
Sorry to post this question again, I still can't solve the problem. Any help
will be very appreciated!


Can anybody tell me how to map DateTime MySql field in OJB?


My realization is the next:



userDateInserted - of type java.util.Date.

After setting the Date, OJB inserts right date. But time is 1 hour minus of
the actual time (minutes and seconds are right).
Interesting, the userDateInserted has right Date value, but after passing it
thru OJB, Date is decreased for 1 hour...
Is it some kind of a bug?
Am I doing something wrong?
Any suggestions?


Regards,
Mykola Ostapchuk


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



Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3

2003-07-08 Thread Mykola Ostapchuk
Hello,

I've spent 2 days trying to migrate my application from OJB 0.9.7 to OJB
1.0.rc3, and still no success.
The problem is - I can't instantiate broker with the next line:
broker = PersistenceBrokerFactory.defaultPersistenceBroker();

I'm using default OJB.properties from 1.0 rc3. I have db-ojb-1.0.rc3.jar and
all additional *.jar files in /lib folder.
I debug RepositoryXmlHandler and it seems there're no problems (see code
snap from pevious message below).

Line:
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
generates some error I don't know how to cach.
log.error in cach statement doesn't print anything.


try {
  broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  usersVO.setUsername(username);
  usersVO.setPassword(password);
  Query query = new QueryByCriteria(usersVO);
  usersVO = (UsersVO) broker.getObjectByQuery(query);
} catch (Exception e) {
  log.error("PersistenceBrokerException thrown in UsersDAO.findByUP(): "
+ e.toString());
}


With OJB 0.9.7 everything works fine.
I'll very appreciate any help!


Regards,
Mykola Ostapchuk






- Original Message - 
From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 11:52 AM
Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3


> Sorry for the previous message. Here's the log:
>
>
> 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - startDoc
> 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler -  >
> descriptor-repository
> 0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - < documentation
> 15DEBUG [Thread-5] metadata.RepositoryXmlHandler -   >
class-descriptor
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
isolation-level:
> read-uncommitted
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  class:
> com.iprs.web.users.UsersVO
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  proxy: null
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  table: users
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  row-reader:
null
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  extends: null
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  accept-locks:
> true
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  accept-locks:
> true
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
> initialization-method: null
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  refresh: true
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
> field-descriptor
> 31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name: userId
> 46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column: US_id
> 46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
> BIGINT




> > [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: endDoc
> >
> >
> >
> > - Original Message - 
> > From: "Thomas Mahler" <[EMAIL PROTECTED]>
> > To: "OJB Users List" <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 08, 2003 1:57 AM
> > Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3
> >
> >
> > > this is most likely a problem during the parsing of the repository.
> > > please set the debug level for XmlRepositoryHandler to DEBUG to see
> > > where the repository problems are.
> > >
> > > cheers,
> > > Thomas
> > >
> > > Mykola Ostapchuk wrote:
> > > > Hello,
> > > >
> > > > I have a problem with migrating from OJB 0.9.7 to OJB 1.0.rc3.
> > > > What I did:
> > > > - replaced db-ojb-0.9.7.jar with db-ojb-1.0.rc3.jar.
> > > > - built new OJB  internal DB tables.
> > > > - replaced old OJB.properties with a new one.
> > > > - replaced repository.dtd with  a new one.
> > > > - modified repository.xml for a new version.
> > > >
> > > > I can't instantiate broker. I see no error messages:
> > > >
> > > > try {
> > > >   log.info("Can see this message***");
> > > >   broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> > > >   log.info("Can not see this
message***");
> > > > } catch (Exception e) {
> > > >

Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3

2003-07-08 Thread Mykola Ostapchuk
Sorry for the previous message. Here's the log:


0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - startDoc
0 DEBUG [Thread-5] metadata.RepositoryXmlHandler -  >
descriptor-repository
0 DEBUG [Thread-5] metadata.RepositoryXmlHandler - < documentation
15DEBUG [Thread-5] metadata.RepositoryXmlHandler -   > class-descriptor
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  isolation-level:
read-uncommitted
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  class:
com.iprs.web.users.UsersVO
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  proxy: null
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  table: users
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  row-reader: null
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  extends: null
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  accept-locks:
true
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  accept-locks:
true
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -
initialization-method: null
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  refresh: true
31DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
field-descriptor
31DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name: userId
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column: US_id
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
BIGINT
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  primarykey: true
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  nullable: true
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  indexed: false
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  autoincrement:
true
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  sequence-name:
null
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  locking: false
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  update-lock:
true
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  conversion: null
46DEBUG [Thread-5] metadata.RepositoryXmlHandler - <
field-descriptor
46DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
field-descriptor
46DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name: username
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column:
US_username
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
VARCHAR
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  primarykey:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  nullable: true
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  indexed: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  autoincrement:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  sequence-name:
null
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  locking: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  update-lock:
true
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  conversion: null
62DEBUG [Thread-5] metadata.RepositoryXmlHandler - <
field-descriptor
62DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
field-descriptor
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name: password
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column:
US_password
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
VARCHAR
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  primarykey:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  nullable: true
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  indexed: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  autoincrement:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  sequence-name:
null
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  locking: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  update-lock:
true
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  conversion: null
62DEBUG [Thread-5] metadata.RepositoryXmlHandler - <
field-descriptor
62DEBUG [Thread-5] metadata.RepositoryXmlHandler - >
field-descriptor
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  name:
userFirstName
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  column:
US_f_name
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  jdbc-type:
VARCHAR
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  primarykey:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  nullable: true
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  indexed: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  autoincrement:
false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  sequence-name:
null
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  locking: false
62DEBUG [Thread-5] metadata.RepositoryXmlHandler -  

Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3

2003-07-08 Thread Mykola Ostapchuk
Hello,

I've set org.apache.ojb.broker.metadata.RepositoryXmlHandler.LogLevel=DEBUG
Here's what I've got:

[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: startDoc
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:
accept-locks: true
[org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: endDoc



- Original Message - 
From: "Thomas Mahler" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 1:57 AM
Subject: Re: Migrating from OJB 0.9.7 to OJB 1.0.rc3


> this is most likely a problem during the parsing of the repository.
> please set the debug level for XmlRepositoryHandler to DEBUG to see
> where the repository problems are.
>
> cheers,
> Thomas
>
> Mykola Ostapchuk wrote:
> > Hello,
> >
> > I have a problem with migrating from OJB 0.9.7 to OJB 1.0.rc3.
> > What I did:
> > - replaced db-ojb-0.9.7.jar with db-ojb-1.0.rc3.jar.
> > - built new OJB  internal DB tables.
> > - replaced old OJB.properties with a new one.
> > - replaced repository.dtd with  a new one.
> > - modified repository.xml for a new version.
> >
> > I can't instantiate broker. I see no error messages:
> >
> > try {
> >   log.info("Can see this message***");
> >   broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> >   log.info("Can not see this message*******");
> > } catch (Exception e) {
> >   log.info("Can not see this message***");
> > }
> >
> > Is there something I've missed?
> >
> >
> > Regards,
> > Mykola Ostapchuk
> >
> >
> > -
> > 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]



Migrating from OJB 0.9.7 to OJB 1.0.rc3

2003-07-07 Thread Mykola Ostapchuk
Hello,

I have a problem with migrating from OJB 0.9.7 to OJB 1.0.rc3.
What I did:
- replaced db-ojb-0.9.7.jar with db-ojb-1.0.rc3.jar.
- built new OJB  internal DB tables.
- replaced old OJB.properties with a new one.
- replaced repository.dtd with  a new one.
- modified repository.xml for a new version.

I can't instantiate broker. I see no error messages:

try {
  log.info("Can see this message***");
  broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  log.info("Can not see this message***");
} catch (Exception e) {
  log.info("Can not see this message***");
}

Is there something I've missed?


Regards,
Mykola Ostapchuk


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



DateTime conversion problem

2003-07-07 Thread Mykola Ostapchuk
Hello,

Can anybody tell me how to map DateTime MySql field in OJB?


My realisation is the next:



userDateInserted - of type java.util.Date.

After setting the Date, OJB inserts right date. But time is 1 hour minus
of actual time (minutes and seconds are right).
Any suggestions?


Regards,
Mykola Ostapchuk

DateTime in OJB

2003-07-07 Thread Mykola Ostapchuk
Hello,

Can anybody tell me how to map DateTime MySql field in OJB?


My realisation is the next:



userDateInserted - of type java.util.Date.

After setting the Date, OJB (?) inserts right date. But time is 1 hour minus
of actual time (minutes and seconds are right).
Any suggestions?


Regards,
Mykola


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



Re: Re[2]: RsIterator question

2003-07-02 Thread Mykola Ostapchuk
Thank you! Sounds good to me - I'll try this approach.

Regards,
Mykola

- Original Message - 
From: "Jin Bal" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, July 02, 2003 10:54 AM
Subject: Re: Re[2]: RsIterator question


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


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



Re: RsIterator question

2003-07-02 Thread Mykola Ostapchuk
The main reason I'm using getIteratorByQuery is because my DB table is
pritty big (~100 000 records). Putting all the records into Collection is
too memory expensive.

I'll very appreciate any help of dealing with big DB tables.


> Hello Mykola,
>
> MO> I'm using  broker.getIteratorByQuery(query);  to return Iterator of
all
> MO> Users in DB.
> MO> Then I pass this Iterator to JSP page (or Struts  MO> as the result it displays nothing.
> MO> I'm not sure it's the problem with OJB, but - if I pass to JSP page
> MO> Iterator, created from a Collection - it works OK.
> MO> Maybe OJB's Iterator - RsIterator doesn't work this way?
>
> MO> By the way - is using broker.getIteratorByQuery() the best way to deal
with
> MO> displaying big DB tables?
> I think no - because of when you get Iterator, OJB will generate SQL
> for each iter.next() call.
> maybe will be better to use getCollectionByQuery() - in this case
> you'll get whole collection at time.
>
> but of course I may be wrong.
>
> -- 
> Best regards,
>  Alexandermailto:[EMAIL PROTECTED]


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



RsIterator question

2003-07-02 Thread Mykola Ostapchuk
Hello,

I'm using  broker.getIteratorByQuery(query);  to return Iterator of all
Users in DB.
Then I pass this Iterator to JSP page (or Struts 

RsIterator question

2003-07-01 Thread Mykola Ostapchuk
Hello,

I'm using  broker.getIteratorByQuery(query);  to return Iterator of all
Users in DB.
Then I pass this Iterator to JSP page (or Struts 

Re: Update only some fields in DB

2003-06-29 Thread Mykola Ostapchuk
Sorry, Thomas, maybe I wasn't clear enough in my question. I need to update
both - in one case - all fields, in another - just some fields.
So, modifying ClassDescriptor to accept only particular fields will help
only with one case...

For now, according to Christophe Marcout, the only way to accomplish my task
is to get an Object from DB with a
getObjectByQuery() method call first, then set any of updates I want.

So, to make  this "universal" update - I need 2 steps - 2 database calls -
Select Object - Store Object.
With SQL language, as we know,  there's just one DB call for Update.
Is this way really the only way to make update with OJB?

Best regards,
Mykola


- Original Message - 
From: "Thomas Mahler" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Sunday, June 29, 2003 5:13 AM
Subject: Re: Update only some fields in DB


> Hi
>
> Mykola Ostapchuk wrote:
> > Hello,
> >
> > This question already was in this maillist, but nobody answered.
>
> I answered it on 19.6.:
>
> You can modify the ClassDescriptor of your peristent class to only
> contain FieldDescriptors of the the PK and modified field.
>
> OJB will then only work with those two columns!
>
> cheers,
> Thomas
>
> > It's actually so fundamental in use, that it must be somewhere in FAQ.
> >
> > So, here it is: How can I update not all, but only some fields in some
> > table? I'm using PersistenceBroker.store method to persist an object -
and
> > if I don't populate all the object properties with values, I get null
rows
> > in DB in place of unspecified object properties...
> > At least, please, answer if it's possible with OJB.
> >
> >
> > Best regards,
> > Mykola Ostapchuk
> >
> >
> > -
> > 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]



Update only some fields in DB

2003-06-28 Thread Mykola Ostapchuk
Hello,

This question already was in this maillist, but nobody answered.
It's actually so fundamental in use, that it must be somewhere in FAQ.

So, here it is: How can I update not all, but only some fields in some
table? I'm using PersistenceBroker.store method to persist an object - and
if I don't populate all the object properties with values, I get null rows
in DB in place of unspecified object properties...
At least, please, answer if it's possible with OJB.


Best regards,
Mykola Ostapchuk


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



Getting refreshed data from DB

2003-06-27 Thread Mykola Ostapchuk
Hello,

I need help to force OJB to get data from database.
My problem: when I insert/modyfy/delete records manually from MySql console,
OJB keeps previous Vector of results (during running Tomcat).
Only after restarting Tomcat I can see "updated" records in my browser.
I thougth setting refresh="true" in class-descriptor will help, but it
didn't...

DAO:
Criteria criteria = new Criteria();
criteria.addOrderBy("CO_order");
criteria.addOrderBy("CO_name");
System.out.println("Critiera:" + criteria.toString());
Query query = QueryFactory.newQuery(CountriesVO.class,
criteria);
query.setStartAtIndex(1);
broker = ServiceLocator.getInstance().findBroker();
results = (Vector) broker.getCollectionByQuery(query);


Table mapping:


 
 
 
 


Please, help!


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



"Refresh" attribute question

2003-06-26 Thread Mykola Ostapchuk
Hello,

I'm new to OJB. Can anybody explain to me the purpose of "refresh" attribute
for reference-descriptor?
All I found is: "The refresh attribute can be set to true to force OJB to
refresh object references on instance loading. "...

The second - I don't understand why this attribute by default is "false"?
When I'm doing any update to "parent" table - "child" table is populated
with NULL values if "refresh" is set to "false".
I just don't see the reason - why BY DEFAULT "parent" object in "child"
table shouldn't change.
Or maybee I'm missing something?


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



Re: Update in 1-m relationship question

2003-06-25 Thread Mykola Ostapchuk
> Mykola Ostapchuk wrote:
>
> >Hello,
> >
> >I'm having problem updating records in 1-m relationship.
> >I have 2 tables - Users and UsersRoles. 1 User can have 1-m UserRoles.
When
> >I delete user - it automatically deletes all the UserRoles - so it works
> >well. But when I update - as I understand, it should first delete all
> >UsersRoles and then insert new ones.  Now it doesn't delete - only
inserts
> >new UserRoles.
> >Should I delete all UsersRoles by myself before updating User or there's
> >something wrong with my configuration/files?
> >
> >repository.xml:
> >
> >
> >  >primarykey="true" autoincrement="true"/>
> >  >jdbc-type="VARCHAR"/>
> >  >jdbc-type="VARCHAR"/>
> >  >element-class-ref="com.name.wos.users.UsersRolesVO" auto-retrieve="true"
> >auto-update="true" auto-delete="true">
> >
> > 
> >
> >
> > >table="usersroles">
> >   >primarykey="true" autoincrement="true"/>
> >   >jdbc-type="BIGINT"/>
> >   >jdbc-type="BIGINT"/>
> >
> >
> >
> >update DAO:
> >
> > public void update(ValueObject updateRecord) throws DataAccessException
{
> >PersistenceBroker broker = null;
> >try {
> >UsersVO usersVO = (UsersVO) updateRecord;
> >broker = ServiceLocator.getInstance().findBroker();
> >broker.beginTransaction();
> >broker.store(usersVO);
> >broker.commitTransaction();
> >} catch (PersistenceBrokerException e) {
> >broker.abortTransaction();
> >e.printStackTrace();
> >throw new DataAccessException("Error in UsersDAO.update()",
e);
> >} catch (ServiceLocatorException e) {
> >throw new DataAccessException("ServiceLocatorException error
in
> >UsersDAO.update()",e);
> >} finally {
> >if (broker != null) broker.close();
> >}
> >}
> >
> >
> >UsersVO.java:
> >
> >import java.util.*;
> >import com.name.wos.common.ValueObject;
> >
> >public class UsersVO extends ValueObject {
> >
> >private Long userId;
> >private String username;
> >private String password;
> >private Vector userUR = new Vector(); // of type UsersRolesVO
> >
> >public Long getUserId() {
> >return userId;
> >}
> >public void setUserId(Long userId) {
> >this.userId = userId;
> >}
> >
> >public String getUsername() {
> >return username;
> >}
> >public void setUsername(String username) {
> >this.username = username;
> >}
> >
> >public String getPassword() {
> >return password;
> >}
> >public void setPassword(String password) {
> >this.password = password;
> >}
> >
> >public Vector getUserUR() {
> >return userUR;
> >}
> >public void setUserUR(Vector userUR) {
> >this.userUR=userUR;
> >}
> >
> >}
> >

> >
> I would try to do all the modifications to the userUR - Collection that
> is given to you by the system because it is a 'RemovalAwareCollection'.
> this would be my setUserUR method:
>
> public void setUserUR(Vector userUR) {
> this.userUR.clear();
> this.userUR.addAll(userUR);
> }
> and then persist the whole thing.
>
> Matthias Laube.
>

In setter method I'm sending as a parameter Vector of new objects of type
UsersRoles - so If you want to clear all existing UsersRoles - you can't
based on new Vector. The only way I see it - to return a Vector of existing
UserRoles based on UserID - and delete these objects. Then - insert new
ones. But I'll better do it in DAO class, not in VO's setter. What do you
think?
I'm really wondering if (or why) it isn't done automatically by OJB? It's so
common situation. I think this routine must be accomplished by OJB.

Regards,
Mykola Ostapchuk


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



Update in 1-m relationship question

2003-06-24 Thread Mykola Ostapchuk
Hello,

I'm having problem updating records in 1-m relationship.
I have 2 tables - Users and UsersRoles. 1 User can have 1-m UserRoles. When
I delete user - it automatically deletes all the UserRoles - so it works
well. But when I update - as I understand, it should first delete all
UsersRoles and then insert new ones.  Now it doesn't delete - only inserts
new UserRoles.
Should I delete all UsersRoles by myself before updating User or there's
something wrong with my configuration/files?

repository.xml:


 
 
 
 

 



  
  
  



update DAO:

 public void update(ValueObject updateRecord) throws DataAccessException {
PersistenceBroker broker = null;
try {
UsersVO usersVO = (UsersVO) updateRecord;
broker = ServiceLocator.getInstance().findBroker();
broker.beginTransaction();
broker.store(usersVO);
broker.commitTransaction();
} catch (PersistenceBrokerException e) {
broker.abortTransaction();
e.printStackTrace();
throw new DataAccessException("Error in UsersDAO.update()", e);
} catch (ServiceLocatorException e) {
throw new DataAccessException("ServiceLocatorException error in
UsersDAO.update()",e);
} finally {
if (broker != null) broker.close();
}
}


UsersVO.java:

import java.util.*;
import com.name.wos.common.ValueObject;

public class UsersVO extends ValueObject {

private Long userId;
private String username;
private String password;
private Vector userUR = new Vector(); // of type UsersRolesVO

public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}

public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public Vector getUserUR() {
return userUR;
}
public void setUserUR(Vector userUR) {
this.userUR=userUR;
}

}

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



Update in 1-m relationship question

2003-06-24 Thread Mykola Ostapchuk
Hello,

I'm having problem updating records in 1-m relationship.
I have 2 tables - Users and UsersRoles. 1 User can have 1-m UserRoles. When
I delete user - it automatically deletes all the UserRoles - so it works
well. But when I update - as I understand, it should first delete all
UsersRoles and then insert new ones.  Now it doesn't delete - only inserts
new UserRoles.
Should I delete all UsersRoles by myself before updating User or there's
something wrong with my configuration/files?

repository.xml:


 
 
 
 

 



  
  
  



update DAO:

 public void update(ValueObject updateRecord) throws DataAccessException {
PersistenceBroker broker = null;
try {
UsersVO usersVO = (UsersVO) updateRecord;
broker = ServiceLocator.getInstance().findBroker();
broker.beginTransaction();
broker.store(usersVO);
broker.commitTransaction();
} catch (PersistenceBrokerException e) {
broker.abortTransaction();
e.printStackTrace();
throw new DataAccessException("Error in UsersDAO.update()", e);
} catch (ServiceLocatorException e) {
throw new DataAccessException("ServiceLocatorException error in
UsersDAO.update()",e);
} finally {
if (broker != null) broker.close();
}
}


UsersVO.java:

import java.util.*;
import com.name.wos.common.ValueObject;

public class UsersVO extends ValueObject {

private Long userId;
private String username;
private String password;
private Vector userUR = new Vector(); // of type UsersRolesVO

public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}

public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public Vector getUserUR() {
return userUR;
}
public void setUserUR(Vector userUR) {
this.userUR=userUR;
}

}

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