RE: Intercepting updates and inserts

2004-06-02 Thread Coup, Robert Muir
Hi,
 
That seems like it will do what I need. I'll let you all know what I figure out.
 
Thanks 
 
Rob :) 



From: Ron Gallagher [mailto:[EMAIL PROTECTED]
Sent: Mon 31-May-04 4:17 p.m.
To: OJB Users List
Subject: RE: Intercepting updates and inserts



Robert --

Check out these two interfaces:

org.apache.ojb.broker.PBLifeCycleListener
org.apache.ojb.broker.PBStateListener

The PBLifeCycleListener provides callbacks that reflect all object-level
operations (lookup, insert, update, delete).  This is probably what you'll
want to utilize.  The PBStateListener interface provides callbacks that
reflect "PersistenceBroker-level" operations (open, close, begin, commit,
rollback).

Both of the interfaces referenced above extend
org.apache.ojb.broker.PBListener.  So, if you've got an object that
implements one or both of these interfaces, you can use the
org.apache.ojb.broker.PersistenceBroker::addListener(PBListener) method to
register that object as a 'listener'.

On my last project, we made extensive use of these listener interfaces for
the same reasons you've described.  In our situation, we had our own
'factory' object that was used to serve up PersistenceBroker instances, so
it was easy enough for us to set up one or more listeners before we served
up any PersistenceBrokers.

Ron Gallagher
Atlanta, GA
ron dot gallagher at bellsouth dot net


-Original Message-
From: Coup, Robert Muir [mailto:[EMAIL PROTECTED]
Sent: Sunday, May 30, 2004 12:51 AM
To: OJB Users List
Subject: Intercepting updates and inserts


Hi all,

We're using OJB to interface our application to an online database
(Postgre) as well as an offline database (HSQLDB). I'm in the process of
writing some simple replication code to allow offline updates to be
reconciled when the data is synchronised with the online database.

What I would like to do is to intercept each update or delete being run
by OJB and log some information about it (statement type, table, user,
time, etc) it to another table. I could make all the persistent objects
implement PersistenceBrokerAware and then do the logging in afterUpdate
and afterDelete, but that isn't a stunningly elegant solution and I was
wondering if there was another place I could hook into which wouldn't
involve making changes to my persistent classes? If not, where would be
the best place to jump into the OJB source to do what I need?

Thanks again,

Rob :)

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




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




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

Intercepting updates and inserts

2004-05-29 Thread Coup, Robert Muir
Hi all,

We're using OJB to interface our application to an online database
(Postgre) as well as an offline database (HSQLDB). I'm in the process of
writing some simple replication code to allow offline updates to be
reconciled when the data is synchronised with the online database.

What I would like to do is to intercept each update or delete being run
by OJB and log some information about it (statement type, table, user,
time, etc) it to another table. I could make all the persistent objects
implement PersistenceBrokerAware and then do the logging in afterUpdate
and afterDelete, but that isn't a stunningly elegant solution and I was
wondering if there was another place I could hook into which wouldn't
involve making changes to my persistent classes? If not, where would be
the best place to jump into the OJB source to do what I need?

Thanks again,

Rob :)

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



RE: Additional properties for connection.

2004-05-24 Thread Coup, Robert Muir
Hi,

For postgresql we just add it to the dbAlias attribute
Eg. Dbalias="//myserver.example.com?ssl" to use a ssl connection
Following the same logic you could use something like 

dbAlias="//myserver.example.com?charSet=Big5&prop2=value2&prop3=value3"

Good luck,

Rob :)


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Monday, 24 May 2004 6:27 a.m.
> To: [EMAIL PROTECTED]
> Subject: Additional properties for connection.
> 
> hello, all!
> 
> Is it possible to specify some additional properties, that 
> should be used for creation the connection in OJB?
> 
> For example, I need to create connection something like this:
> 
> // Load the JDBC-ODBC bridge driver
>Class.forName(sun.jdbc.odbc.JdbcOdbcDriver) ;
>  
>// setup the properties 
>java.util.Properties prop = new java.util.Properties();
>prop.put("charSet", "Big5");
>prop.put("user", username);
>prop.put("password", password);
>  
>// Connect to the database
>con = DriverManager.getConnection(url, prop);
> 
> How can I specify in repository.xml some additional 
> properties (like charSet in prop object) for connection?
> Or it is impossible?
> 
> Best Regards,
> Alexey Kakunin
> Project Manager
> PIKOS GmbH
> Post Str. 24
> 53111 Bonn
> 
> Tel: +49 30 43 72 92-30
> Fax: +49 30 43 72 92-30
> 

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



ProxyHelper.getRealClass(o) != ProxyHelper.getRealObject(o).getClass()

2004-04-15 Thread Coup, Robert Muir
Hi,

Fairly self explanatory 

I'm using RC5 - does anyone have any ideas why this might occur (or has
it been fixed - I couldn't find anything in the CVS changelogs)?

Situation:

Interfaces/Inheritance hierarchy:
 AbstractEntity
   - Group*
 - StaffGroup*
 - StudentGroup*
   - AbstractPerson

The classes have implementations defined by xxImpl. Classes marked by *
are proxied (dynamic)

It works ok except occassionally there have been issues comparing
classes so in those cases we were using ProxyHelper.getRealClass()

Now we found an interesting case - the object is a GroupImpl
 ProxyHelper.getRealClass() returns StaffGroupImpl (?!)
 ProxyHelper.getRealObject().getClass() returns GroupImpl like it
should...

If it's a new problem I'll try and wrap it into a TestCase...

Thanks for your help,

Rob :)

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



Multiple ODMG Databases open concurrently

2004-03-25 Thread Coup, Robert Muir
Hi all,

Situation: 
We use a single data/db model which can either be an online network
database (PGSql) or an offline local one (HSQLDB). At startup time, the
user chooses which to use, and we just apply a different
connection-descriptor. That all works great.

Now one feature requires a connection to the online db and we wanted
this to be made accessible for the offline users if they happen to be
connected. I need to have 2 odmg connections open at the same time for a
short period - is this possible? From a quick look through the OJB &
DatabaseImpl docs it seems that OJB only supports a single open db...

Are there workarounds other than closing and opening each in turn?

Thanks for your help,

Rob :)

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



RE: [OTM] bi-directional 1:n not working

2004-03-03 Thread Coup, Robert Muir
Any chance you could post a summary of what you learnt?

Thanks,

Rob :) 

> -Original Message-
> From: Weaver, Scott [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 4 March 2004 11:48 a.m.
> To: 'OJB Users List'
> Subject: RE: [OTM] bi-directional 1:n not working
> 
> Hi Oleg,
> 
> I had a long IM conversation with Matt Baird today and he set 
> me straight on how to use OTM and otm-dependent.  However, I 
> am still getting the NullPointerExceptions when invalidating 
> or using the empty cache impl (see my other posts).
> 
> 
> Regards,
> ** 
> | Scott T Weaver |
> | <[EMAIL PROTECTED]>| 
> | Apache Jetspeed Portal Project |
> | Apache Pluto Portlet Container |
> **
> 
> > -Original Message-
> > From: Oleg Nitz [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 03, 2004 6:58 PM
> > To: OJB Users List
> > Subject: Re: [OTM] bi-directional 1:n not working
> > 
> > On Wednesday 03 March 2004 16:50, Weaver, Scott wrote:
> > > Removing these appears to have fixed this:
> > >
> > > auto-delete="true"
> > > auto-update="true"
> > > auto-retrieve="true"
> > >
> > > I thought OTM could co-exists with these settings?  I 
> guess I was wrong.
> > 
> > auto-retrieve="true" is okay
> > AFAIK auto-update="true" and auto-delete="true" are okay, 
> unless you 
> > set otm-dependent="true". When you add otm-dependent="true"
> > don't
> > forget to remove auto-update="true" and auto-delete="true".
> > Anyway I don't understand how auto-update="true" can affect setting 
> > object references to parents.
> > 
> > Regards,
> >  Oleg
> > 
> > 
> > 
> -
> > 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: [OTM] bi-directional 1:n not working

2004-03-01 Thread Coup, Robert Muir
I'm having a great day, so ignore the previous post. :P

Is appId field in the PortletDefinitionImpl populated when you retrieve
it (as opposed to the app reference)?

Rob :)



> -Original Message-
> From: Weaver, Scott [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 2 March 2004 10:49 a.m.
> To: 'OJB Users List'
> Subject: [OTM] bi-directional 1:n not working
> 
> 
> 
> I have a PortletApplicationDefinitionImpl contains n 
> PortletDefinitionImpl s.  Each portlet definition has a 
> reference back to its parent PortletApplicationDefinition.  
> PortletApplicationDefinitionImpl works correctly and its 
> collection of PortletDefinitionImpls is populated. However, 
> anytime I retrieve a PortletDefinitionImpl the reference to 
> its parent PortletApplicationDefinitionImpl is always null.  
> 
> 
> Regards
> ** 
> | Scott T Weaver |
> | <[EMAIL PROTECTED]>| 
> | Apache Jetspeed Portal Project |
> | Apache Pluto Portlet Container |
> **
> 
> 
> 

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



RE: [OTM] bi-directional 1:n not working

2004-03-01 Thread Coup, Robert Muir
Hi,

Could you send the relevant parts of your repository.xml?

Rob :)

> -Original Message-
> From: Weaver, Scott [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 2 March 2004 10:49 a.m.
> To: 'OJB Users List'
> Subject: [OTM] bi-directional 1:n not working
> 
> 
> 
> I have a PortletApplicationDefinitionImpl contains n 
> PortletDefinitionImpl s.  Each portlet definition has a 
> reference back to its parent PortletApplicationDefinition.  
> PortletApplicationDefinitionImpl works correctly and its 
> collection of PortletDefinitionImpls is populated. However, 
> anytime I retrieve a PortletDefinitionImpl the reference to 
> its parent PortletApplicationDefinitionImpl is always null.  
> 
> 
> Regards
> ** 
> | Scott T Weaver |
> | <[EMAIL PROTECTED]>| 
> | Apache Jetspeed Portal Project |
> | Apache Pluto Portlet Container |
> **
> 
> 
> 

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



RE: Transaction Question.

2004-02-09 Thread Coup, Robert Muir
Hi,

There can only be one ODMG transaction open per thread. 

Thanks,
Rob :)

> -Original Message-
> From: Ziv Yankowitz [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 10 February 2004 5:39 a.m.
> To: OJB (E-mail)
> Subject: Transaction Question.
> 
> 
> Folks,
> 
> Is Nested Transaction supported within ODMG?
> 
> assuming we have the following  :
> 
> within the same Thread.
> 
> Transaction1 start 
>   Transaction2 start
>   Transaction2 finish 
>   Transaction1 finish.
> 
> Thanks.
> 
> 
> -
> 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: Forcing materialization of a dynamic proxy object

2004-02-02 Thread Coup, Robert Muir
Hi,

That worked beautifully! This class needs to be added in the docs
somewhere...

Thanks,
Rob :)

> -Original Message-
> From: Thierry Hanot [mailto:[EMAIL PROTECTED] 
> Sent: Monday, 2 February 2004 8:33 p.m.
> To: 'OJB Users List'
> Subject: RE: Forcing materialization of a dynamic proxy object
> 
> 
> Try this 
> It should work :)
> 
> import org.apache.ojb.broker.util.ProxyHelper;
> 
> 
> ...
> 
> ProxyHelper.getRealObject(iter.next());
> 
> 
> B.R 
> 
> T.H
> 
> 
> -Original Message-
> From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 02, 2004 4:27 AM
> To: [EMAIL PROTECTED]
> Subject: Forcing materialization of a dynamic proxy object
> 
> 
> Hi all,
> 
> I have searched through the archives and can't seem to find 
> any answer. How can I force a proxy to materialize its 
> object, or to replace the proxy object witht the real object?
> 
> I have a collection of Group objects within a Paper object. 
> Group's are proxied dynamically (group, staffgroup), and can 
> be of two types - groupimpl or staffgroupimpl. Groupimpl is 
> the parent of staffgroupimpl.
> 
> When the Paper objects collection arrives, it is a bunch of 
> proxy objects. In one operation, I must manipulate the 
> staffgroups in the paper.groups collection.
> 
> For (Iterator iter=groups.iterator; iter.hasNext;) {
>   Group g = (Group)iter.next();
>   if (g instanceof StaffGroup) {
>   ...
>   }
> }
> 
> This fails because none of the objects are seen as 
> StaffGroup's. Even attempting to resolve them through a call 
> to .getSomething() seems to leave the objects as $Proxy2's
> 
> Ideas?
> 
> Thanks,
> Robert Coup
> 
> 
> 
> Classes:
>   Interface Group
>   Interface StaffGroup extends Group
>   
>   Class GroupImpl implements Group
>   Class StaffGroupImpl extends GroupImpl implements StaffGroup
> 
> Repository:
> 
> 
> 
> 
>  proxy="dynamic">
>    Fields ...
> 
> 
> 
> 
> 
>  proxy="dynamic">
>    Fields ...
> 
> 
> 
>    Fields ...
>  name="groups" 
> element-class-ref="Group"
> auto-retrieve="true"
> auto-update="false"
> >
>   ...
> 
> 
> 
> -
> 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]



Forcing materialization of a dynamic proxy object

2004-02-01 Thread Coup, Robert Muir
Hi all,

I have searched through the archives and can't seem to find any answer.
How can I force a proxy to materialize its object, or to replace the
proxy object witht the real object?

I have a collection of Group objects within a Paper object. Group's are
proxied dynamically (group, staffgroup), and can be of two types -
groupimpl or staffgroupimpl. Groupimpl is the parent of staffgroupimpl.

When the Paper objects collection arrives, it is a bunch of proxy
objects.
In one operation, I must manipulate the staffgroups in the paper.groups
collection.

For (Iterator iter=groups.iterator; iter.hasNext;) {
Group g = (Group)iter.next();
if (g instanceof StaffGroup) {
...
}
}

This fails because none of the objects are seen as StaffGroup's. Even
attempting to resolve them through a call to .getSomething() seems to
leave the objects as $Proxy2's

Ideas?

Thanks,
Robert Coup



Classes:
Interface Group
Interface StaffGroup extends Group

Class GroupImpl implements Group
Class StaffGroupImpl extends GroupImpl implements StaffGroup

Repository:





 Fields ...






 Fields ...



 Fields ...

...



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



RE: complex joins

2004-02-01 Thread Coup, Robert Muir
Reading your question a bit more.

Do you actually want to customize your queries for specific
collection-descriptors (which is what QueryCustomizer is for), or do you
just want to perform complex queries?

If its the second option, complex queries are relatively straightforward
once you get the hang of them. See the tutorials and query docs on the
OJB site, and search the mailing list archives if you run into trouble.
You don't want to use querycustomizer.

Rob :)

> -Original Message-
> From: monish [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 27 January 2004 8:24 a.m.
> To: [EMAIL PROTECTED]
> Subject: complex joins
> 
> 
> Hi,
> 
> I'm relatively new to OJB. Mapping simple queries was easy, however 
> when it comes to complex queries, its not very clear which 
> straegy to use.
> 
> Can someone help out. 
> 
> The query we trying to do is
> 
> SELECT D.col1
>  , D.col2
>  , D.col3
>   FROM $test.tableAA 
>  , $test.tableB   B 
>  , $test.tableC  C
>  , $test.tableD   D
>  
>  WHERE A.ITEM_STRUC_ID  = '001'   
>AND A.LVL_RPT_CD = '60998030' 
>AND A.EFCT_DT   <= CURRENT DATE
>AND A.EXPR_DT   >  CURRENT DATE 
>
>AND B.ITEM_STRUC_ID  = A.ITEM_STRUC_ID 
>AND B.ANC_LVL_ID = A.ITEM_LVL_ID   
>AND B.EFCT_DT   <= CURRENT DATE
>AND B.EXPR_DT   >  CURRENT DATE
>AND B.VRTL_IND   = 'R'   
>   
>AND C.ITEM_STRUC_ID  = B.ITEM_STRUC_ID 
>AND C.ITEM_LVL_ID= B.ITEM_LVL_ID   
>AND C.EFCT_DT   <= CURRENT DATE
>AND C.EXPR_DT   >  CURRENT DATE
> 
>AND D.KGF_STD_ITEM_CDE   = C.KF_STD_ITEM_NBR
>AND CURRENT TIMESTAMP  BETWEEN D.EFFECTIVE_TMSTMP
>AND D.END_EFFECT_TMSTMP
>AND D.col3   IN ('A', 'D')
>  ORDER BY 
> 
> 
> thanks
> 
> Monish
> 
> 
> -
> 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: complex joins

2004-02-01 Thread Coup, Robert Muir
Hi,

It's not too difficult - basically your querycustomizer gets called with
what it thinks is the query to run based on the collection-descriptor,
etc. Then you can add/adjust/replace the query it is going to perform
with something that suits better.

Very simple example (for this collection, get all A's where A.id_parent
is null)
the customizer is set up on the collection descriptor for a's.

...
public Query customizeQuery(Object anObject, PersistenceBroker
aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery) {
aQuery.getCriteria().addIsNull("id_parent");
return aQuery;
}
...

Good luck, 
Rob :)

> -Original Message-
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of monish
> Sent: Friday, 30 January 2004 5:00 a.m.
> To: [EMAIL PROTECTED]
> Subject: Re: complex joins
> 
> 
> Reading the docn I suspect QueryCustomizer should be used 
> when the join criteria is anything other than equality (like <, >)
> 
> Can someone point me to the place to look examples 
> for this.
>  
> thanks
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



RE: How to setup this query with OJB-PB

2004-02-01 Thread Coup, Robert Muir
Hi,

Minor assumption/clarification - you want to find all activities with no
schedules (where activities is on the 1 side and schedules are on the N
side). 

I'm struggling with something similar (only its nasty m:n) so you're in
luck:

crit.addIsNull("schedules.uid");// pk of
schedule
newQuery = QueryFactory.newQuery(Activity.class, crit, true);
newQuery.setPathOuterJoin("schedules"); // collection name as
declared in repository

This will effectively do a
  SELECT activity.* 
  FROM activity LEFT OUTER JOIN schedule ON (activity.id =
schedule.activity_id)
  WHERE (schedule.id IS NULL)
Which should return what you want. Also much nicer/faster than an IN
query.

Good luck,
Rob :)

> -Original Message-
> From: Dirk Manske (Service Respond) 
> [mailto:[EMAIL PROTECTED] 
> Sent: Monday, 2 February 2004 11:49 a.m.
> To: 'OJB Users List'
> Subject: How to setup this query with OJB-PB
> 
> 
> Hi,
> 
> I am using PB API and have two classes Activity and Schedule 
> with 1:N association. Both are declared in the 
> repository-user.xml with a collection-descriptor as 
> reference.  Now I want to process a query which results in a 
> collection with all activities where no schedule has been 
> set. I have read the Query examples carefully but I just 
> don't get it. Could someone help me with the following sql statement:
> 
> SELECT * FROM Activity As act
> 
> WHERE act.ACTIVITY_ID NOT IN
> 
> (SELECT ACTIVITY_ID FROM SCHEDULE);
> 
> 
> Looks so simple, but I cannot figure it out. How to set up 
> this statement using the Criteria class?
> 
> Hope someone can help. thanks,
> 
> Dirk
> 
> 
> -
> 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]



Interfaces and Extents (NPE in TableAlias.hashCode)

2004-01-31 Thread Coup, Robert Muir
Hi all,

I have a complicated situation which I have run into using proxies and
interfaces...

Classes:
Interface Group
Interface StudentGroup extends Group
Interface StaffGroup extends Group

Class GroupImpl implements Group
Class StudentGroupImpl extends GroupImpl implements StudentGroup
Class StaffGroupImpl extends GroupImpl implements StaffGroup

Repository:






 Fields ...










 Fields ...










 Fields ...






One question - is what I've done the 'right' way to map this? Or should
it be more like the following?








My way seems to work okay for queries and operations, except the
following. I have another object (Paper) that uses a QueryCustomizer on
a collection to find Groups which don't belong to other Groups (ie. Are
Top-Level Groups). It is also proxied dynamically.
public Query customizeQuery(Object anObject, PersistenceBroker
aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery) {
ReportQueryByCriteria subQuery;
Criteria subCrit = new Criteria();
Criteria crit = new Criteria();

subCrit.addEqualToField("membership.id",
Criteria.PARENT_QUERY_PREFIX + "id");
subQuery = QueryFactory.newReportQuery(Group.class, subCrit);
subQuery.setColumns(new String[] { "membership.id" });
subQuery.setDistinct(true);

aQuery.getCriteria().addNotIn("id", subQuery);
return aQuery;
}

When the Paper is resolved I get the following:

[org.apache.ojb.broker.accesslayer.IndirectionHandler] ERROR: Method
invoking failed for method *getTitle* on object null
org.apache.ojb.broker.PersistenceBrokerException:
java.lang.NullPointerException
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.PersistenceBrokerException:
java.lang.NullPointerException
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(
IndirectionHandler.java:345)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.getRealSubject(Indi
rectionHandler.java:309)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(IndirectionH
andler.java:284)
at $Proxy5.getTitle(Unknown Source)
at
nz.ac.auckland.markit.netbeans.nodes.PaperNode.(PaperNode.java:93)
at
nz.ac.auckland.markit.netbeans.modules.logindialog.ConnectionManager.loa
dPapers(ConnectionManager.java:123)
at
nz.ac.auckland.markit.netbeans.modules.logindialog.ConnectionManager$1.r
un(ConnectionManager.java:103)
at java.lang.Thread.run(Thread.java:534)
Caused by: org.apache.ojb.broker.PersistenceBrokerException:
java.lang.NullPointerException
at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Que
ryReferenceBroker.java:250)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(Query
ReferenceBroker.java:537)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(Quer
yReferenceBroker.java:695)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Persistence
BrokerImpl.java:1089)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Per
sistenceBrokerImpl.java:1145)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdenti
ty(DelegatingPersistenceBroker.java:296)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdenti
ty(DelegatingPersistenceBroker.java:296)
at
org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(
IndirectionHandler.java:334)
... 7 more
Caused by: java.lang.NullPointerException
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias.hashC
ode(SqlQueryStatement.java:1913)
at java.util.HashMap.hash(HashMap.java:261)
at java.util.HashMap.put(HashMap.java:379)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(Sq
lQueryStatement.java:1614)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.(SqlQueryS
tatement.java:155)
at
org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.(SqlSelec
tStatement.java:104)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.getSubQuerySQL(S
qlQueryStatement.java:915)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSubQuery(S
qlQueryStatement.java:890)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendParameter(
SqlQueryStatement.java:875)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendInCriteria
(SqlQueryStatement.java:727)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendCriteria(S
qlQue

RE: Closing ODMG JDBC Connection

2004-01-28 Thread Coup, Robert Muir
Hi Lance,

Pools are great and I don't really want to get rid of that by using
ConnectionFactoryNotPooledImpl. However, I found part of the answer.
Each of the ConnectionFactory's has a releaseAllResources method which
will close all the connections in the pool (exactly what I want). 

Anyway, after much mailing list searching and code reading this seems to
work...

PersistenceBroker broker 
   =
PersistenceBrokerFactory.createPersistenceBroker(((DatabaseImpl)OJB.getI
nstance().getDatabase(null)).getPBKey());
((ConnectionManagerImpl)broker.serviceConnectionManager()).getUnderlying
ConnectionFactory().releaseAllResources();
OJB.getInstance().getDatabase(null).close();

Relatively nasty... Maybe it should go in the faq or there should be an
easier way of getting to it (there probably is - how?)

Thanks for your help,

Rob :)


> -Original Message-
> From: Lance Eason [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 29 January 2004 12:19 p.m.
> To: OJB Users List
> Subject: RE: Closing ODMG JDBC Connection
> 
> 
> Not closing the connection is kind of the whole point of 
> connection pooling, and OJB provides connection pooling.  
> Database connections are typically expensive to establish, so 
> rather than each time you use the database creating a new 
> connection and then releasing it at the end connections are 
> maintained in a pool and just borrowed for a period of time 
> and then returned so other clients can use them. It looks 
> like you can specify different connection pooling 
> implementations though so what you want is probably to set 
> the following in OJB.properties:
> 
> ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.Conne
> ctionFactoryNotPooledImpl
> 
> -Original Message-
> From: Coup, Robert Muir [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 28, 2004 5:08 PM
> To: [EMAIL PROTECTED]
> Subject: Closing ODMG JDBC Connection
> 
> 
> Hi All,
> 
> We're using a hsqldb database for part of our application, 
> and need to package the database files up into a zip archive 
> before exiting. Problem is, OJB doesn't seem to be closing 
> the database connection so the files are still locked and we 
> can't delete them once they are in the Zip file.
> 
> We use a single db reference throughout out application, 
> initialised by
>   db = OJB.getInstance().newDatabase(null);
> When we go to shut it down, we call
>   db.close();
> 
> Are we missing some obvious step, or do we need to start 
> playing with finalize()? I have tested that hsqldb releases 
> the file locks when the jdbc connection is closed via a call 
> to connection.close().
> 
> Thanks for your help,
> Rob :)
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



Closing ODMG JDBC Connection

2004-01-28 Thread Coup, Robert Muir
Hi All,

We're using a hsqldb database for part of our application, and need to
package the database files up into a zip archive before exiting. Problem
is, OJB doesn't seem to be closing the database connection so the files
are still locked and we can't delete them once they are in the Zip file.

We use a single db reference throughout out application, initialised by
db = OJB.getInstance().newDatabase(null);
When we go to shut it down, we call
db.close();

Are we missing some obvious step, or do we need to start playing with
finalize()? I have tested that hsqldb releases the file locks when the
jdbc connection is closed via a call to connection.close().

Thanks for your help,
Rob :)

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



RE: Optimistic Locking Integer/int Bug

2004-01-20 Thread Coup, Robert Muir

> As you suggested, this is the old int/Integer problem. In OJB 
> the prefered way is to avoid primitives datatypes (as int, 
> boolean) and use only Object datatypes (as Integer, Boolean).
> 
> I think the problem can be solved at the docs. If not then 
> how we can test a int to null in Java? ;)

Yeah I guess the best fix is in the docs. 

Or if ojb_version==0 then
'UPDATE MyClassTable SET ojb_version='1', ... WHERE id='723' AND
(ojb_version='0' OR ojb_version is NULL)'

The issue about it not always failing puzzled me a little. I'll try and
get a test case to reproduce it...

Rob :)

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



Optimistic Locking Integer/int Bug

2004-01-20 Thread Coup, Robert Muir
Hi,

I think I found a minor bug in the optimistic locking (OL)
code/documentation

If you initialise an int field to use OL (locking="true") then updates
will fail if the field is null, either silently or with a
LockNotGrantedException.

public class MyClass {
private Integer id;
private int ojbVersion;
}

 

 
 
If a new object is created and persisted, the ojb_version field is set
to 1 If another app inserts a record and the ojb_version field is null,
when it is persisted then this SQL gets executed.
  UPDATE MyClassTable SET ojb_version='1', ... WHERE id='723' AND
ojb_version='0'

Sometimes this throws an exception, othertimes it seems to silently
fail.

Obviously it's the old int/Integer thing :)
But in
http://db.apache.org/ojb/faq.html#How%20to%20set%20up%20Optimistic%20Loc
king it has:  private int versionMaintainedByOjb

Should the docs be changed to 'private Integer versionMaintainedByOjb'?
If so, will it have issues 'incrementing' a null value? Or should in the
docs it state 'make this table field default to a non-null value (eg.
0)'? Or should the code be doing 'UPDATE MyClassTable SET
ojb_version='1', ... WHERE id='723' AND (ojb_version='0' OR ojb_version
is NULL)'?

Thanks,

Rob :)

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



Optimistic Locking Integer/int bug

2004-01-18 Thread Coup, Robert Muir
Hi,

I think I found a minor bug in the optimistic locking (OL)
code/documentation

If you initialise an int field to use OL (locking="true") then updates
will fail if the field is null, either silently or with a
LockNotGrantedException.

public class MyClass {
private Integer id;
private int ojbVersion;
}

 



 
If a new object is created and persisted, the ojb_version field is set
to 1
If another app inserts a record and the ojb_version field is null, when
it is persisted then this SQL gets executed.
  UPDATE MyClassTable SET ojb_version='1', ... WHERE id='723' AND
ojb_version='0'

Sometimes this throws an exception, othertimes it seems to silently
fail.

Obviously it's the old int/Integer thing :)
But in
http://db.apache.org/ojb/faq.html#How%20to%20set%20up%20Optimistic%20Loc
king it has:
 private int versionMaintainedByOjb

Should the docs be changed to 'private Integer versionMaintainedByOjb'?
If so, will it have issues 'incrementing' a null value? Or should in the
docs it state 'make this table field default to a non-null value (eg.
0)'? Or should the code be doing 'UPDATE MyClassTable SET
ojb_version='1', ... WHERE id='723' AND (ojb_version='0' OR ojb_version
is NULL)'?

Thanks,

Rob :)


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



ODMG Lock Not Granted Exception

2004-01-15 Thread Coup, Robert Muir
Hi All,

I'm having some fun with Optimistic locking. Specifically, I'm trying to
delete a series of objects contained in a collection, and getting the
following error.

org.odmg.LockNotGrantedException: Object has been modified by someone
else
at org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown
Source)
at org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(Unknown
Source)
at org.apache.ojb.odmg.TransactionImpl.prepare(Unknown Source)
at org.apache.ojb.odmg.TransactionImpl.commit(Unknown Source)
at
nz.ac.auckland.markit.netbeans.modules.property.propertyviews.MarkingMap
View.commitTransaction(MarkingMapView.java:432)

Now, I'm the only one using the db. I get the markingMap from the
assessment, deep clone it (setting ID's to null), and let the users
adjust it. 

When they've finished, I delete the entries in the existing markingMap
for the assessment, then add the new entries to the db in their place.

>From debugging and commenting out bits, adding the new entries works,
but deleting the old ones doesn't. The existing MarkingMap entry objects
aren't changed anywhere before I attempt to delete them.

MarkingMap is a little special. Its basically a wrapped list of
MarkeeData objects. And we're referring to it as part of the Assessment
Object via the markingMap::list syntax. This has worked fine before we
were using Optimistic Locking on it, so I'm not sure what's going on now
:)

In OJB.properties, ImplicitLocking is set to false and LockAssociations
is set to read.

Thanks for your help,

Robert

Relevant bits of the repository:

















...






And the original code:
...
Transaction tx =
PersistenceManager.getInstance().getODMG().newTransaction();
Database db = PersistenceManager.getInstance().getOdmgDb();
try{
//Make the new marking map (currMarkingMap) persistent for
currAssessment
tx.begin();

tx.lock(currAssessment, Transaction.WRITE);

// delete the old marking map entries
for (Iterator iter =
currAssessment.getMarkingMap().getData().listIterator();
iter.hasNext();) {
MarkeeData md = (MarkeeData)iter.next();
db.deletePersistent(md);
iter.remove();
}


// add the new entries
currMarkingMap.setAssessment(currAssessment);   // set
all the new entry's assessments to point

// to currentAssessment
for(Iterator iter = currMarkingMap.getData().listIterator();
iter.hasNext();) {
MarkeeData md = (MarkeeData)iter.next();
tx.lock(md, Transaction.WRITE);
}
currAssessment.setMarkingMap(currMarkingMap);   // set the
assessment's marking map to point here.

tx.commit();
}catch(Exception e){  
if (tx.isOpen())
tx.abort();
ErrorManager.getDefault().notify(e);
}
...

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



RE: Ordered Collections, Lists, DList

2004-01-14 Thread Coup, Robert Muir
If anyone is interested, my current solution for one case is:
 1. add an Integer field listIndex to the item object
 2. make the item object PersistenceBrokerAware, and in the
beforeUpdate() method
// update the position of this entry in the list
if (this.parent != null) {
this.listIndex = new
Integer(this.parent.getItemList().indexOf(this));
} else {
this.listIndex = null;
}
 3. to the parent collection-descriptor decalaration, add 
 
Possible issues:
 1. If the order of items in a list is changed, then _all_ the item
objects must be updated so their indexes are stored.

As always, suggestions are welcome.

Thanks,

Rob :)


> -Original Message-
> From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 14 January 2004 12:09 p.m.
> To: [EMAIL PROTECTED]
> Subject: Ordered Collections, Lists, DList
> 
> 
> Hi all,
> 
> What is the best way of storing an ordered list without using 
> Dlist which requires additional tables & SQL lookups? 
> 
> OrderBy works great if the positioning has some underlying 
> field (eg. Object id, name) but if the only thing specifying 
> the position is the list index then it doesn't work too well.
> 
> One option is to link a fake field-descriptor to the item's 
> position in a list and use orderby... Is this what other 
> people are doing?
> 
> Another is to create a new ManageableCollection that is 
> linked somehow to a database field which it stores indexes 
> in... but that breaks the idea that the mapping is in the repository.
> 
> Another is to do something like...
>   name="myList"
>element-class-ref="com.example.MyObject"
>collection-class="com.example.MyMagicList"
>index-field="listIndexField"
>/>
> Then store the index of each item in the list in the database 
> field specified by index-field. When you re-instantiate it is 
> effectively an orderBy. A ManageableList interface extending 
> ManageableCollection may be needed which knows about and uses 
> the index-field attribute... 
> And it probably needs to ignore/complain about additional 
> orderBy fields...
> 
> Is this a good idea? Something worth doing?
> Or am I missing the obvious?
> 
> Thanks again,
> Rob :)
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



RE: Qualified Collection Relationships

2004-01-14 Thread Coup, Robert Muir
Hi,

One problem solved - one to go.

GO is a group. A group has a collection of members (which is a
superclass of group), and has a collection of all groups that contain
it, and has a reference to RO. 
 RO
   + GO
  + MO
 + MO
 + MO
  + MO
  + MO
   + GO

In retrieving the groups in RO, I need to get only those groups where
GO.groupsThatContainMe.size() == 0 Ie. Where there are no parent
groups for this one.

How can I specify this using a PB Query in my QueryCustomizer?

Thanks again for all your help,

Robert



> -Original Message-
> From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 15 January 2004 7:27 a.m.
> To: OJB Users List
> Subject: Re: Qualified Collection Relationships
> 
> 
> hi robert,
> 
> you can solve this problem by using a QueryCustomizer to add 
> additional criteria 
> to the query generated by ojb.
> 
> hth
> jakob
> 
> Coup, Robert Muir wrote:
> 
> > Hi All,
> > 
> > What I have :
> > Root Object RO has:
> >  - a collection of CO objects specified using 
> 
> > 
> > Child Object CO has:
> >  - a collection of CO objects specified using 
> 
> >  - a reference to a parent CO (null if the object has no CO parent)
> >  - a reference to the RO
> > 
> > Example...
> > 
> > RO
> >   + CO
> >  + CO
> > + CO
> > + CO
> >  + CO
> >  + CO
> >   + CO
> >   + CO
> >   
> > However, when my collection of CO's for the RO is built by OJB on 
> > retrieval, it does something like:
> >SELECT * FROM co WHERE co.RO_reference = RO.id
> > This returns all the CO objects, but I only want the direct 
> children 
> > such as:
> >SELECT * FROM co WHERE (co.RO_reference = RO.id) AND 
> (co.CO_parent 
> > =
> > null)
> > 
> > Which I would ideally declare something like:
> > 
> >  > element-class-ref="CO"
> > auto-retrieve="true"
> > auto-update="false"
> > >
> > 
> >  
> > 
> > 
> > I searched the mail archives and came up with some posts 
> saying that 
> > qualified relationships were on the todo list in February 
> 2003... Has 
> > there been any progress since then?
> > 
> > Alternatively, how have other people solved this? Setting 
> > auto-retrieve to false and doing a getCollectionByCriteria() in the 
> > PersistenceBrokerAware afterLookup() method seems like a reasonable 
> > option, but means the business object layer starts to know a little 
> > bit much about the persistence mechanisms...
> > 
> > Thanks for your help,
> > 
> > Robert Coup :)
> > 
> > 
> > 
> -
> > 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: Qualified Collection Relationships

2004-01-14 Thread Coup, Robert Muir
Hi Jakob,

> you can solve this problem by using a QueryCustomizer to add 
> additional criteria 
> to the query generated by ojb.

I found it! It's only mentioned in the O/R mapping tutorial but not is
missing completely from the repository documentation, so I had missed
it.

I think it would be handy to add a reference from the repository docs to
the o/r mapping stuff. (probably from the dtd too since there is no
documentation there either). Just so the repository stays as the
definitive reference on the available options.

Thanks for your help,

Rob :)


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



RE: Cache Mechanism

2004-01-14 Thread Coup, Robert Muir
As I understand it OQL queries always hit the database but the objects
can be resolved from the cache though. If you use the PB API for
accessing objects (you can do this from ODMG) then the cache is accessed
much more.

Good Luck,

Rob :)

-Original Message-
From: Ronen Yaari [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 14 January 2004 8:27 p.m.
To: OJB Users List
Subject: RE: Cache Mechanism



My problem is that when working with the ODMG API with cache definition
I spoted that when making the same call twice it in both cases goes to
the database in order to fetch the data.

To ensure it: before making the second call I deleted the relveant row
from the database and it did not succed to do it afterward altough it
should have been in the cache.

The same scenario worked smoothly with the Broker API.

Am I doing something wrong ?

Ronen.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 13, 2004 9:50 PM
To: OJB Users List
Subject: Re: Cache Mechanism


Hi Ronen,

Ronen Yaari wrote:
> All,
> 
> I noticed that the Cache Mechanism works only with the Broker API, Is 
> it true ?

No.

> I want to use the ODMG API, is it possiblesomehow to use the Cache
Mechanism with this API ?

yes!


What exactly is your problem?
Thomas

> Thanxs,
> 
> Ronen Yaari
> Traiana Technologies
> 
> 
> 
> -
> 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]



Qualified Collection Relationships

2004-01-13 Thread Coup, Robert Muir
Hi All,

What I have :
Root Object RO has:
 - a collection of CO objects specified using 

Child Object CO has:
 - a collection of CO objects specified using 
 - a reference to a parent CO (null if the object has no CO parent)
 - a reference to the RO

Example...

RO
  + CO
 + CO
+ CO
+ CO
 + CO
 + CO
  + CO
  + CO
  
However, when my collection of CO's for the RO is built by OJB on
retrieval, it does something like:
   SELECT * FROM co WHERE co.RO_reference = RO.id
This returns all the CO objects, but I only want the direct children
such as:
   SELECT * FROM co WHERE (co.RO_reference = RO.id) AND (co.CO_parent =
null)

Which I would ideally declare something like:






I searched the mail archives and came up with some posts saying that
qualified relationships were on the todo list in February 2003... Has
there been any progress since then? 

Alternatively, how have other people solved this? Setting auto-retrieve
to false and doing a getCollectionByCriteria() in the
PersistenceBrokerAware afterLookup() method seems like a reasonable
option, but means the business object layer starts to know a little bit
much about the persistence mechanisms...

Thanks for your help,

Robert Coup :)


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



Ordered Collections, Lists, DList

2004-01-13 Thread Coup, Robert Muir
Hi all,

What is the best way of storing an ordered list without using Dlist
which requires additional tables & SQL lookups? 

OrderBy works great if the positioning has some underlying field (eg.
Object id, name) but if the only thing specifying the position is the
list index then it doesn't work too well.

One option is to link a fake field-descriptor to the item's position in
a list and use orderby... Is this what other people are doing?

Another is to create a new ManageableCollection that is linked somehow
to a database field which it stores indexes in... but that breaks the
idea that the mapping is in the repository.

Another is to do something like...

Then store the index of each item in the list in the database field
specified by index-field. When you re-instantiate it is effectively an
orderBy. A ManageableList interface extending ManageableCollection may
be needed which knows about and uses the index-field attribute... 
And it probably needs to ignore/complain about additional orderBy
fields...

Is this a good idea? Something worth doing?
Or am I missing the obvious?

Thanks again,
Rob :)

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



RE: FW: NetBeans and OJB

2004-01-13 Thread Coup, Robert Muir
Hi,

I really strongly suggest you make a module using an ANT build file.
There are lots of docs on the netbeans site and templates in the
OpenAPIs Support module. Otherwise it will just get messier and messier
every time you try to do something.

Once you have a module, use nice netbeans-style paths to access all your
resources.

Rob :)


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



RE: FW: NetBeans and OJB

2004-01-12 Thread Coup, Robert Muir
Hi,

> No Success! :(  I've mounted a directory c:\work\test and 
> OJB.properties is in it. What should I type after nz/ ?

Ah. By nz/... I meant your path to the OJB properties file relative to
the mount point
It needs to be in a subfolder under the mountpoint otherwise NB won't
resolve it.

E.g.
C:\bob\jim\ojb\OJB.properties
C:\bob is mounted in the filesystem
System.setProperty("OJB.properties", "jim/ojb/OJB.properties");

> 
> What about repository.dtd ? How should I reference it from 
> repository.xml ? using file:///c://... ?

Change it to "repository.dtd" and put it in the same folder as the
respository.xml

> Should I also put jdbc driver jar in nb-home/lib/ext ?
> 
> Sould I also put my own application classes ?

Depends on the options I described previously, but yes, your JDBC driver
jar should be included somewhere.

Good Luck,

Rob :)

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



RE: FW: NetBeans and OJB

2004-01-11 Thread Coup, Robert Muir
> You need the ojb libraries in your classpath. This either means - 
>  - make a module, declare dependencies and install the libs 
> in netbeans-dir/modules/ext
>  - do it the nasty way and install in netbeans-dir/lib/ext
> 

Or alternatively, the pinnacle of nastiness, build a jar file with all
the OJB dependent classes from all the jars included directly.

Rob :)

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



RE: FW: NetBeans and OJB

2004-01-11 Thread Coup, Robert Muir
Hello,

Sorry about the late reply.
We're using Netbeans to develop an app which also uses OJB, so I've been
there and done this :)

Before initialisation (ie. Any ojb-calls )
...
System.setProperty("OJB.Properties",
"nz/ac/auckland/markit/ojb/OJB.properties")
...
ie. Using the netbeans-style resource referencing...
I also found if you wanted to set spy.properties/log4j.properties then
you needed to do the same thing

In OJB.properties
...
repositoryFile=nz/ac/auckland/markit/ojb/respository.xml
...

Now, here's the trick.
You need the ojb libraries in your classpath. This either means - 
 - make a module, declare dependencies and install the libs in
netbeans-dir/modules/ext
 - do it the nasty way and install in netbeans-dir/lib/ext

Good luck.

Rob :)

> -Original Message-
> From: Muhammad Aamir [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, 10 January 2004 3:04 a.m.
> To: OJB Users List
> Subject: RE: FW: NetBeans and OJB
> 
> 
> Edson,
> 
> Although I had tried to set complete path of OJB.properties 
> (by System.setProperty("OJB.properties", 
> "C:/work/easy/OJB.properties") ) and repository.xml (I've 
> changed the repository.xml path in OJB.properties using 
> file:///c:/work/easy/repository.xml) the problem had not been solved.
> 
> But I'll try to apply this again. In the mean time I'll be 
> appreciate if someone could give me a clue for this problem.
> 
> Thank you v. much
> Aamir
> 
> -Original Message-
> From: Edson Carlos Ericksson Richter 
> [mailto:[EMAIL PROTECTED] 
> Sent: Friday, January 09, 2004 6:47 PM
> To: OJB Users List
> Subject: Re: FW: NetBeans and OJB
> 
> Hi!
> 
> I could answer you question. In NetBeans, go to
> 
> Tools -> Options -> Debbuging and Executing -> Execution 
> Types -> External Execution -> Expert -> Working Directory.
> 
> Unfortunately, there is no equivalent option for Internal 
> Execution (but the default execution for NetBeans apps is 
> External Execution). In Internal Execution mode, the Working 
> Directory is the NetBeans bin directory. So, if you need to 
> use Internal Execution, you should set complete path for 
> repository/ojb.properties.
> 
> I sugest you to use External Execution, and set Working 
> Directory (to avoid annoiances).
> 
> I've collected these info in more than a year working with 
> OJB inside NetBeans.
> 
> 
> Best regards,
> 
> Edson Richter
> 
>   - Original Message - 
>   From: Muhammad Aamir 
>   To: OJB Users List 
>   Sent: Friday, January 09, 2004 9:38 AM
>   Subject: RE: FW: NetBeans and OJB
> 
> 
>   NetBeans IDE is a wonderful modular application and you can 
> develop your
>   own application on top of NetBeans platform. I want to use NetBeans
>   platform and my developed modules to build my application.
> 
>   The answer of your question that why I am using internal 
> execution, is
>   that I want to do some experiments with Open IDE API (an API to
>   communicate with NetBeans IDE components). And internal 
> execution uses
>   the same virtual machine in which NetBeans IDE is running.
> 
>   Aamir
> 
>   -Original Message-
>   From: Thomas Dudziak [mailto:[EMAIL PROTECTED] 
>   Sent: Friday, January 09, 2004 5:20 PM
>   To: OJB Users List
>   Subject: RE: FW: NetBeans and OJB
> 
>   Well, I'm no expert when it comes to NetBeans (I prefer 
> Eclipse). What
>   is
>   the benefit of internal execution vs. external execution ?
> 
>   Tom
> 
> 
> 
>   
> -
>   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]
> 
> 
> 
>   ---
>   Outgoing mail is certified Virus Free.
>   Checked by AVG anti-virus system (http://www.grisoft.com).
>   Version: 6.0.558 / Virus Database: 350 - Release Date: 2/1/2004
> 
> -
> 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: ojb_dlist_entries continues to grow ...

2004-01-07 Thread Coup, Robert Muir
Hi,

Are you creating Dlist's within a transaction and then not persisting
them? I ran into this issue amd didn't really find a satisfactory
answer...
I would really like to use a general list class (with ordering!) that
can be made persistent but doesn't need the overhead/space of re-storing
every entry in the DLIST tables... Let alone entries/lists that were
never persisted!

Maybe someone else has some new ideas

Rob :)

> -Original Message-
> From: Gunnar Hilling [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 7 January 2004 9:06 p.m.
> To: [EMAIL PROTECTED]
> Subject: ojb_dlist_entries continues to grow ...
> 
> 
> Hello all,
> 
> Is it normal, that the ojb_dlist_entries table grows on and 
> on? Or ist this just caused by rollbacked transactions?
> 
> I think I'll have soon problems because my database becomes 
> quite large just by ojb_dlist_entries...
> 
> Any clue?
> 
> -Gunnar
> 
> 
> 
> -
> 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: Persisting Date and Time

2004-01-07 Thread Coup, Robert Muir
Hi Fabiano,

Try JDBC-TYPE='TIMESTAMP' - and try and use java.sql.Date instead of java.util.Date... 
I have run into problems before with java.util.Date but YMMV.

Good Luck,

Rob :)

> -Original Message-
> From: Fabiano Fernandes de Souza [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 8 January 2004 2:08 a.m.
> To: [EMAIL PROTECTED]
> Subject: Persisting Date and Time
> 
> 
> 
> I got in a value object a property named recDate of java.util.Date.
> 
> It's mapped in resource.xml as jdbc-type="DATE" and 
> mapped in the ddl as rec_date TIMESTAMP.
> 
> I persist the object with the current Date using something 
> like: "setRecDate(new Date()) and then I persist it using ODMG.
> 
> Everything goes fine but in the table keeps registered only 
> the date (not date and time) like this: 2004-01-06 00:00:00
> 
> What can I do to register the date and the time too?
> 
> Thanks.
> -- 
> Fabiano F. Souza
> Tecnologia da Informação
> Estudar Soluções em Treinamento Corporativo.
> (31) 32849294 - [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: SequenceManagerMySQLImpl

2004-01-07 Thread Coup, Robert Muir
Hi Claudio

OJB's autoincrement is completely separate from the database/table
autoincrement

Good luck,

Rob :)

> -Original Message-
> From: Claudio Romano [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 7 January 2004 11:53 p.m.
> To: OJB Users List; [EMAIL PROTECTED]
> Subject: RE: SequenceManagerMySQLImpl
> 
> 
> Hi Thomas,
> 
> thanks for the quick anwer! The tables that throws this 
> exceptions don't have any autoincrement field on the 
> database! So i can't declare this attribute?!
> 
> Or am i missing something?
> 
> Thanks
> Claudio Romano
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, January 07, 2004 11:47 AM
> To: OJB Users List
> Subject: Re: SequenceManagerMySQLImpl
> 
> 
> Hi Claudio,
> 
> To work with sequence numbering you have to declare the respective 
> attribute as autoincrement="true".
> If you don't do this you can not expect the sequence manager 
> to work for
> 
> those tables!
> 
> Thomas
> 
> Claudio Romano wrote:
> > Hi all,
> > 
> > i updated OJB from the rc3 to rc5. Now i have a problem with tables 
> > without an auto increment field. The Method "afterStore" in the
> > SequenceManagerMySQLImpl
> > class alway throws ArrayIndexOutOfBoundsException on these tables.
> > 
> > Am i doing something wrong?
> > 
> > This change causes my exception:
> > 
> > diff -u -r1.14 -r1.15
> > public void afterStore(JdbcAccess dbAccess, ClassDescriptor cld,
> Object
> > obj) 
> >  throws SequenceManagerException
> >  {
> >  
> > -FieldDescriptor fd = cld.getAutoIncrementField();
> > +FieldDescriptor fd = cld.getAutoIncrementFields()[0];
> > 
> > 
> > 
> > Thanks
> > Claudio Romano
> > 
> > 
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
One more important thing.

Make sure your primary keys are unique across Documents _and_ Downloads.
Ie. If there is document #10 there should never be download #10

This is because they are in the same extent. If you retrieve a
collection of SupportItemI's then they need to have unique IDs, or a Bad
Thing(TM) will occur.

Depending on your DBMS, you can do this in a number of ways.
http://db.apache.org/ojb/sequencemanager.html explains it. 
Set the same sequence-name for the primary key fields for all classes in
an extent (download and document).

Rob :)

> -Original Message-
> From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 6 January 2004 12:35 p.m.
> To: OJB Users List
> Subject: Re: How to combine two non-decomposed m:n mappings 
> in one collection?
> 
> 
> ... and now for something completely different:
> 
> do i even have define foreign key constraints in my 
> database??? I'm having the 
> impression that OJB is handling all the joins. Is it enough 
> to have some loose 
> tables in my DB ???
> 
> Patrick
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
> The scenario is this: a PalModel should have a collection of 
> SupportItemsI and a 
> Keyword should have a collection of support items.
> Keyword doesn't relate to pal_model.

Okay. So what was in my last email should work :)

> Something else just came to my mind: a category should also 
> have a collection of 
> SupportItemsI... h. now it get's tricky...
> 


  ... Fields ...
  




And in download if you want to be able to navigate to category using a
'myCategory' field 
(if you only want to navigate from category to download, don't worry)


  ... Fields including 'category_id' ...
  ... Other collections for model/keywords ...

  

 


And similarly for document and role if you need it...

Rob :)

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
> ... and now for something completely different:
> 
> do i even have define foreign key constraints in my 
> database??? I'm having the 
> impression that OJB is handling all the joins. Is it enough 
> to have some loose 
> tables in my DB ???


Well, it's up to you.

OJB can and will do it anyway. If you want to use the database from
somewhere else (ie. Not going through OJB - maybe direct JDBC or
whatever) then it is probably a good idea so your data doesn't get
screwed up (which will then confuse OJB). :)

Rob :)

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
Hi,

> As you can see on the picture i adopted your t_ prefix for tables :-)
It makes 
> the repository.xml a lot easier to read! I hope you don't have a
copyright on it ;-)

Yes. Well, I also got sick of playing with tables named 'user' and
'group' in projects - they need to be specified as '[user]' and
'[group]' in SQL for a number of dbms'...

> To remove any potential for misunderstanding (and since I'm a visual
person :-)) 
> I uploaded a new version of the data model picture:
> http://homepage.hispeed.ch/tabalooga/datamodel-redesign.jpg

Hmmm... now I'm confused again. :) Ah, you snuck in some other changes -
keyword now relates to pal_model? Or maybe not...
*** Assuming you want keyword and pal_model separate ***

There's no need to define SupportItemI as a class with a table since it
has no fields. It just tells OJB that Document and Download are related
and can be referred to by other persistent classes as a SupportItemI

Now ignoring role, category, user_role, and user:

Tables required:
T_download
T_document
T_pal_model
T_pal_model_supportitem
T_keyword_supportitem

Java Classes required:
SupportItemI Interface
Download (implements SupportItemI)
Document (implements SupportItemI)
Pal_model
Keyword

OJB Repository:

  
  



  ... Field Descriptors ...
  


  
 


  ... Field Descriptors ...
  


  
 


  ... Field Descriptors ...
  


  
  


  



  ... Field Descriptors ...
  


  
  


  



-Original Message-
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 11:38 a.m.
To: OJB Users List
Subject: Re: How to combine two non-decomposed m:n mappings in one
collection?


Coup, Robert Muir wrote:

> Well, I would call it t_pal_model_supportitemI, and its a replacement 
> for t_pal_model_document AND t_pal_model_download

I guess that's what I wanted to say :-)

> Tell us how you get on.

To remove any potential for misunderstanding (and since I'm a visual
person :-)) 
I uploaded a new version of the data model picture:

http://homepage.hispeed.ch/tabalooga/datamodel-redesign.jpg

Patrick


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


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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
Hi,



> This sounds interesting. Just let me make sure I got it right: I have
to create a new table t_download_supportitemI which has a m:n mappings
to 
> t_download and and one to t_document (pretty much a replacement for
t_pal_model) 

Well, I would call it t_pal_model_supportitemI, and its a replacement
for t_pal_model_document AND t_pal_model_download

> and t_pal_model has a 1:n mapping to t_pal_model_supportitemI... is
that correct?

That was the idea. OJB _should_ be able to figure it out based on the
extents and retrieve the document/download from the correct table. 


One fix (which is probably why you got confused):

> 
>   ... Field Descriptors ...
>  element-class-ref="pal_model"
>   indirection-table="t_pal_model_supportitems"
<
>   >
>   
>   
>   
> 

Tell us how you get on.

Rob :)


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



RE: HSQLDB + JBoss Help (Function is Not Supported SQL Exception)

2004-01-05 Thread Coup, Robert Muir
mpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at 
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stat
elessSessionContainer.java:660)
at 
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(
CachedConnectionInterceptor.java:186)
at 
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Statele
ssSessionInstanceInterceptor.java:77)
at 
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterce
ptor.java:107)
at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptor
CMT.java:210)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.jav
a:130)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
at 
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer
.java:313)
at org.jboss.ejb.Container.invoke(Container.java:738)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at 
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:383
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.ja
va:701)
at java.lang.Thread.run(Thread.java:534)
2004-01-05 16:52:52,542 DEBUG 
[org.apache.ojb.broker.accesslayer.StatementManager] closeResources was 
called
2004-01-05 16:52:52,542 INFO 
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] Rollback was 
called, do rollback on current connection null
2004-01-05 16:52:52,542 DEBUG 
[org.apache.ojb.broker.core.PersistenceBrokerImpl] PB.close was called: 
[EMAIL PROTECTED]
2004-01-05 16:52:57,489 DEBUG 
[org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] Resized cache 
for bean ConferenceAbstractStatus: old capacity = 100, new capacity
= 50



Brian Sam-Bodden wrote:

> Coup, Robert Muir wrote:
> 
>> If you use hsqldb in client-server mode you can set it up to log all 
>> the sql queries (see Advanced Topics in the HSQLDB docs). Or 
>> configure p6spy to do the same thing on the OJB side... This might 
>> give you some ideas about what it is trying to do...
>>
>> I assume that your db connection in the repository is set to use the 
>> HSQLDB driver, etc?
>>
>> Good luck,
>>
>> Rob :)
>>
> 
> Rob,
>   Thanks a bunch for responding. Here's some more info. I'm in the
> process of trying the P6SPY stuff right now.
> 
> here's my repository_database:
> 
>  jcd-alias="tcms"
> default-connection="true"
> platform="Hsqldb"
> driver="org.hsqldb.jdbcDriver"
> jdbc-level="2.0"
> jndi-datasource-name="java:tcmsDS"
> username="sa"
> password=""
> eager-release="true"
> batch-mode="false"
> useAutoCommit="0"
> ignoreAutoCommitExceptions="false">
> 
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImp
l"/> 
> 
> 
> 
> Thanks,
>   Brian


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


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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
Hi,

Did you see my response to your other post? Please reply to the list.

Cheers,

Rob :)

-Original Message-
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 10:17 a.m.
To: OJB Users List
Subject: How to combine two non-decomposed m:n mappings in one
collection?


Hi,

I have the following problem:

I have a table keywords which has two non-decomposed m:n mappings to the
tables 
document and file. The latter two both implement the interface
SupportItem. In 
my Keyword class i would like to have a collection of all SupportItems
for this 
keyword.
Is it possible to declare two indirection-tables in a
collection-descriptor? If not, how could this be accomplished? Can OJB
handle such a case?

Thanks a lot!
Patrick


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

--- Begin Message ---
Hi Patrick.

Is the field doc_id in download_pal_model actually meant to be model_id?
Otherwise I am a touch confused :)

Also, I assume you've checked out the advanced O/R mapping stuff at
http://db.apache.org/ojb/tutorial3.html - if not, do it now!

Idea #1:
  For download -> model

  ... Field Descriptors ...

  


  

  And going from model -> download...

  ... Field Descriptors ...

  


  


Okay, that's a simple non-decomposed M:N and you probably know that
already ... That doesn't really help with the single-collection issue at
all.


Idea #2:
How about:

  
  



  ... Field Descriptors ...
  


  
 


  ... Field Descriptors ...
  


  


You should be able to keep your object design the same and just modify
the tables a bit so there is one table for both relations... Still
non-decomposed :)

#3:
Implement pal_model_download and pal_model_document as classes,
extending a common class (ModelContents). Then ...


  
  



  ... Field Descriptors ...
  

  
 


  ... Field Descriptors ...
  

  



  
  
  

  
  

  


This will make the object model a bit harder, since
model.collectionOfSupportItemIs will return ModelContent objects, not
actual Downloads/Documents (i.e decomposed M:N) but you can keep the
existing table stuff.



Others may have better ideas :)

Good Luck,

Rob :)



-Original Message-
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Friday, 2 January 2004 2:56 p.m.
To: OJB Users List
Subject: Mapping Question


Hi,

Please see the attached image of my data model for reference (I'm sorry
for the 
attachment but it's kind of complicated to describe the scenario
otherwise. A 
picture says more than a thousand words :-) ).

How do I map the relationship between pal_model - download and pal_model
- document? The corresponding value objects (DownloadVO and DocumentVO)
both implement the 
Interface SupportItemI.
My PalModelVO has a collection which holds all the SupportItemIs for a
PalModelVO.

How can I map a collection that gets it's data from two m-n
relationships? Can I 
specify two indirection tables? Do i have to change my data model?

Any comments and suggestions are welcome.

I wish everybody a peaceful, prosperous and happy new year! Patrick


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




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

RE: timestamp problem with mysql

2004-01-05 Thread Coup, Robert Muir
Hi,

AFAIK, fields of TIMESTAMP type in mysql automatically fill themselves
with the current time/date if you INSERT or UPDATE them to null
values... Maybe you should use a mysql DATETIME field which is
essentially the same data type, just without the automatic cleverness?

Rob :)

-Original Message-
From: Ramon Cano Granizo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 8:00 a.m.
To: [EMAIL PROTECTED]
Subject: timestamp problem with mysql


Hello all,


i'm inserting a timestamp with obj rc4 in mysql, with a null value,
but mysql insert the actual date. It's a bug, must i make a special
mapping??

Thanks a lot

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



RE: Getting the Id in insertion time.

2004-01-05 Thread Coup, Robert Muir
Well...

>From the tutorial...

public class Product
{
/** Artificial primary-key */
private Integer id;

/** price per item*/
private Double price;

/** stock of currently available items*/
private Integer stock;

/** product name*/
private String name;

/* Getters and Setters not shown for tutorial */
}

CREATE TABLE product
(
id INTEGER PRIMARY KEY,
name VARCHAR(100),
stock INTEGER,
price DOUBLE
)

   
  
  
  
  
   


...
Then after you have stored a product using transction.commit() (you said you were 
using odmg) you should be able to get the unique id/primary key from myProduct.id...

See the tutorials at http://db.apache.org/ojb/user-docs.html for more info :)

Good Luck,
Rob :)


-Original Message-
From: Fabiano Fernandes de Souza [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 11:33 a.m.
To: [EMAIL PROTECTED]
Subject: RE: Getting the Id in insertion time.


Can I ?
How I am stupped! hehehe
:-)

Thank you.

Fabiano.
Em Ter, 2004-01-06 às 04:48, Coup, Robert Muir escreveu:
> Can't you just look at the primary key field (eg myObject.oid) of the 
> object to retrieve the id value? OJB/ODMG will automatically set this 
> value when the object is persisted/retrieved...
> 
> Rob :)
> 
> -Original Message-
> From: Fabiano Fernandes de Souza [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 6 January 2004 3:01 a.m.
> To: [EMAIL PROTECTED]
> Subject: Getting the Id in insertion time.
> 
> 
> 
> I'm using auto-increment fields.
> The OJB defines the new ID for this fields when I insert a new record. I would like 
> to know how can I know those new ID's values after the insert task using ODMG.
> 
> There's a function that record the object in the database and return 
> the ID value?
> 
> Otherwise, what can I do?
-- 
Fabiano F. Souza
Tecnologia da Informação
Estudar Soluções em Treinamento Corporativo.
(31) 32849294 - [EMAIL PROTECTED]


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



RE: HSQLDB + JBoss Help (Function is Not Supported SQL Exception)

2004-01-05 Thread Coup, Robert Muir
If you use hsqldb in client-server mode you can set it up to log all the
sql queries (see Advanced Topics in the HSQLDB docs). Or configure p6spy
to do the same thing on the OJB side... This might give you some ideas
about what it is trying to do...

I assume that your db connection in the repository is set to use the
HSQLDB driver, etc?

Good luck,

Rob :)

-Original Message-
From: Brian Sam-Bodden [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 7:33 a.m.
To: [EMAIL PROTECTED]
Subject: HSQLDB + JBoss Help (Function is Not Supported SQL Exception)


HEEELPP!

I've worked throught most of the my configuration woes with OJB, JBoss 
3.0.8 and HSQLDB. Everthing seems to be in place and I can query objects

from the DB without a problem. The only problem is saving my objects to 
the DB. I get a SQL error (function not supported).

Here's the Session Bean code...

/**
  * @author mailto:[EMAIL PROTECTED]">Brian
Sam-Bodden
  *
  * @ejb.bean
  *  name="ConferenceFacade"
  *  type="Stateless"
  *  view-type="both"
  *  jndi-name="ejb.ConferenceFacadeHome"
  *  local-jndi-name="ejb.ConferenceFacadeLocalHome"
  * @ejb.transaction
  *  type="Required"
  * @ejb.util
  *  generate="physical"
  */
public abstract class ConferenceFacadeBean implements SessionBean { ...
 /**
  * @ejb.interface-method
  * @ejb.transaction
  *  type="NotSupported"
  *
  * @return
  */
 public Collection getAllConferences() {
 PersistenceBroker broker = pbf.defaultPersistenceBroker();
 Collection allConferences = Collections.EMPTY_LIST;

try {
 Query query = new QueryByCriteria(Conference.class, null);
 allConferences = broker.getCollectionByQuery(query);
 } catch (PersistenceBrokerException pbe) {
 throw new EJBException("Could not retrieve list of 
conferences");
 } finally {
 if (broker != null)broker.close();
}

return allConferences;
 }

 /**
  * @ejb.interface-method
  * @ejb.transaction
  *  type="NotSupported"
  *
  * @return
  */
 public boolean saveConference(Conference conference) {
 PersistenceBroker broker = pbf.defaultPersistenceBroker();
 boolean result = true;

try {
broker.beginTransaction();
 broker.store(conference);
broker.commitTransaction();
 } catch (PersistenceBrokerException pbe) {
 result = false;
 broker.abortTransaction();
 } finally {
 if (broker != null) broker.close();
}

return result;
 }  

The conference POJO

package com.ejdoab.pojos;

import java.io.Serializable;
import java.util.Date;

/**
  * @ojb.class
  * generate-table-info="true"
  * table="conferences"
  */
public class Conference implements Serializable {

/**
 * @ojb.field
 * column="PK_ID"
 * jdbc-type="INTEGER"
 * primarykey="true"
 * autoincrement="true"
 */ 
protected Integer id;

/**
 * @ojb.field
 * column="NAME"
 * jdbc-type="VARCHAR"
 */
protected String name;

/**
 * @ojb.field
 * column="DESCRIPTION"
 * jdbc-type="LONGVARCHAR"
 */ 
protected String description;

/**
 * @ojb.field
 * column="STARTDATE"
 * jdbc-type="DATE"
 */ 
protected Date startDate;

/**
 * @ojb.field
 * column="ENDDATE"
 * jdbc-type="DATE"
 */
protected Date endDate;

/**
 * @ojb.field
 * column="ABSTRACTSUBMISSIONSTARTDATE"
 * jdbc-type="DATE"
 */ 
protected Date abstractSubmissionStartDate;

/**
 * @ojb.field
 * column="ABSTRACTSUBMISSIONENDDATE"
 * jdbc-type="DATE"
 */ 
protected Date abstractSubmissionEndDate;

/**
 * no-arg constructor
 */
public Conference() {
}

/**
 * all-args constructor
 *
 * @param id
 * @param name
 * @param description
 * @param startDate
 * @param endDate
 * @param abstractSubmissionStartDate
 * @param abstractSubmissionEndDate
 */
public Conference(
Integer id,
String name,
String description,
Date startDate,
Date endDate,
Date abstractSubmissionStartDate,
Date abstractSubmissionEndDate) {
this.id = id;
this.name = name;
this.descri

RE: Getting the Id in insertion time.

2004-01-05 Thread Coup, Robert Muir
Can't you just look at the primary key field (eg myObject.oid) of the object to 
retrieve the id value? OJB/ODMG will automatically set this value when the object is 
persisted/retrieved...

Rob :)

-Original Message-
From: Fabiano Fernandes de Souza [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 3:01 a.m.
To: [EMAIL PROTECTED]
Subject: Getting the Id in insertion time.



I'm using auto-increment fields. 
The OJB defines the new ID for this fields when I insert a new record. I would like to 
know how can I know those new ID's values after the insert task using ODMG.

There's a function that record the object in the database and return the ID value?

Otherwise, what can I do?

-- 
Fabiano F. Souza
Tecnologia da Informação
Estudar Soluções em Treinamento Corporativo.
(31) 32849294 - [EMAIL PROTECTED]


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


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



RE: Mapping Question

2004-01-04 Thread Coup, Robert Muir
Hi Patrick.

Is the field doc_id in download_pal_model actually meant to be model_id?
Otherwise I am a touch confused :)

Also, I assume you've checked out the advanced O/R mapping stuff at
http://db.apache.org/ojb/tutorial3.html - if not, do it now!

Idea #1:
  For download -> model

  ... Field Descriptors ...

  


  

  And going from model -> download...

  ... Field Descriptors ...

  


  


Okay, that's a simple non-decomposed M:N and you probably know that
already ... That doesn't really help with the single-collection issue at
all.


Idea #2:
How about:

  
  



  ... Field Descriptors ...
  


  
 


  ... Field Descriptors ...
  


  


You should be able to keep your object design the same and just modify
the tables a bit so there is one table for both relations... Still
non-decomposed :)

#3:
Implement pal_model_download and pal_model_document as classes,
extending a common class (ModelContents). Then ...


  
  



  ... Field Descriptors ...
  

  
 


  ... Field Descriptors ...
  

  



  
  
  

  
  

  


This will make the object model a bit harder, since
model.collectionOfSupportItemIs will return ModelContent objects, not
actual Downloads/Documents (i.e decomposed M:N) but you can keep the
existing table stuff.



Others may have better ideas :)

Good Luck,

Rob :)



-Original Message-
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Friday, 2 January 2004 2:56 p.m.
To: OJB Users List
Subject: Mapping Question


Hi,

Please see the attached image of my data model for reference (I'm sorry
for the 
attachment but it's kind of complicated to describe the scenario
otherwise. A 
picture says more than a thousand words :-) ).

How do I map the relationship between pal_model - download and pal_model
- document? The corresponding value objects (DownloadVO and DocumentVO)
both implement the 
Interface SupportItemI.
My PalModelVO has a collection which holds all the SupportItemIs for a
PalModelVO.

How can I map a collection that gets it's data from two m-n
relationships? Can I 
specify two indirection tables? Do i have to change my data model?

Any comments and suggestions are welcome.

I wish everybody a peaceful, prosperous and happy new year! Patrick


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



RE: Ojb samples

2003-12-29 Thread Coup, Robert Muir
I assume you mean repository.xml

If so:
   



  

This uses Postgre's sequences to generate keys for different extents. See the tutorial 
docs and the sequence manager docs for more information.

Thanks,
Rob :)


-Original Message-
From: Fabiano Fernandes de Souza [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 30 December 2003 10:22 a.m.
To: [EMAIL PROTECTED]
Subject: Ojb samples


Please,

Can anyone send to me some resource.xml source code fragment where is declared the 
jdbc-connection-descriptor for a postgresql jdbc?

I am a newbie and my bigest problems is to start to use it on my Web application. I 
couldnt find any samples how to use it on Web Applications. Some codes of config files 
and servlets using the ojb framework for inserts or queries would be fine.

Thanks.
-- 
Fabiano F. Souza
Tecnologia da Informação
Estudar Soluções em Treinamento Corporativo.
(31) 32849294 - [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]



Ordered Lists and Index Fields

2003-12-23 Thread Coup, Robert Muir
Hi all,

What is the best way of storing an ordered list without using Dlist
which requires additional tables & SQL lookups? 
OrderBy works great if the positioning has some underlying field (eg.
Object id, name) but if the only thing specifying the position is the
list index then it doesn't work too well.

One option is to link a fake field-descriptor to the item's position in
a list and use orderby... 
Another is to create a new ManageableCollection that is linked somehow
to a database field which it stores indexes in... but that breaks the
idea that the mapping is in the repository.

Another is to do something like...

Then store the index of each item in the list in the database field
specified by index-field. When you re-instantiate it is effectively an
orderBy.
A ManageableList interface extending ManageableCollection may be needed
which knows about and uses the index-field attribute... 
And it probably needs to ignore/complain about additional orderBy
fields...

Suggestions? Alternatives?

Thanks again,
Rob :)

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



RE: Re: InitializerError + OJBRuntimeException

2003-12-23 Thread Coup, Robert Muir
Of course, this is OJB :)

OJB.properties location & name can be specified through a call to 
System.setProperty("OJB.properties", ) before anything is done.
In the OJB.properties file you can specify the location and name of the
repository.xml file.

Have fun,
Rob :)


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 24 December 2003 7:07 a.m.
To: [EMAIL PROTECTED]
Subject: Aw: Re: InitializerError + OJBRuntimeException


Hi Armin,

thanks for your hint. OJB.properties has not been on the classpath
indeed. Now it works. However, I do not feel very comfortable with so
many property files (ojb, repository.xml ...) on the classpath. Is there
another way, so I can store these files where ever I want in my web
application and reference them?

greets,
Dirk


- Original Nachricht 
Von: Armin Waibel <[EMAIL PROTECTED]>
An:  OJB Users List <[EMAIL PROTECTED]>
Datum:   23.12.2003 09:51
Betreff: Re: InitializerError + OJBRuntimeException

> Hi Dirk,
> 
>  > I am wondering about the OJBRuntimeExeception: what kind of 
> property
> key is
>  > missed?
> 
>  > Caused by: org.apache.ojb.broker.OJBRuntimeException: Property for 
> key  > 'PersistenceBrokerFactoryClass' can not be found in properties 
> file  > at 
> org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.init(Unknow
> nSourc
> 
> 
> Seems OJB can't find OJB.properties file. Make sure that you include 
> all
> configuration files in classpath.
> 
> regards,
> Armin
> 
> Dirk Manske (mobil) wrote:
> > Hi,
> >  
> > I am new to OJB and get stuck with the following exception message:
> >  
> > java.lang.ExceptionInInitializerError
> >  at
> >
> org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroke
> r(Unkn
> 
> > own Source)
> >  at
> >
> de.premiere.plato.app.dao.ojb.OJBPBPersistenceManager.storeObject(OJBP
> BPersi
> 
> > stenceManager.java:159)
> >  at
> >
> de.premiere.plato.test.activity.control.TestDatabase.testStoreObject(T
> estDat
> 
> > abase.java:56)
> >  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39
> 
> > )
> >  at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl
> 
> > .java:25)
> >  at java.lang.reflect.Method.invoke(Method.java:324)
> >  at junit.framework.TestCase.runTest(TestCase.java:154)
> >  at junit.framework.TestCase.runBare(TestCase.java:127)
> >  at junit.framework.TestResult$1.protect(TestResult.java:106)
> >  at junit.framework.TestResult.runProtected(TestResult.java:124)
> >  at junit.framework.TestResult.run(TestResult.java:109)
> >  at junit.framework.TestCase.run(TestCase.java:118)
> >  at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >  at junit.framework.TestSuite.run(TestSuite.java:203)
> >  at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> TestRu
> 
> > nner.java:392)
> >  at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> unner.
> 
> > java:276)
> >  at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> Runner
> 
> > .java:167)
> > Caused by: org.apache.ojb.broker.OJBRuntimeException: Property for 
> > key 'PersistenceBrokerFactoryClass' can not be found in properties 
> > file  at
> org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.init(Unknow
> n
> > Source)
> >  at
> >
> org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.(Un
> known
> > Source)
> >  ... 18 more
> >  
> >  
> > it happens after executing this method:
> > 
> > public void storeObject(Object object) throws 
> > PersistenceServiceException
> {
> > try{
> > broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
> > 
> > broker.store(object);
> > }
> > catch(Exception e){
> > //TODO Catch Klausel kommentieren
> > throw new PersistenceServiceException("storeObject
failed");
> > 
> > }
> > finally{
> > broker.close();
> > }
> > }
> > 
> > I am wondering about the OJBRuntimeExeception: what kind of property

> > key
> is
> > missed?
> > 
> > thx,
> > Dirk
> >  
> > 
> > 
> > 
> > -
> > 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]