Associating an outer join with a value for a report

2003-08-01 Thread Jim Moore
First, what I'm trying to accomplish...

I need to get this SQL:

SELECT t.name, l.meaning
FROM tasks t, lookup l
WHERE t.userid =  AND
 l.lookup_code (+) = t.lang AND
 l.lookup_type (+) = 'PREFERRED_LANGUAGE'


Currently I have this

Task:

  


Lookup:




Unfortunately, it can't think of how to express the relationship in the
above SQL in the XML.  So I tried doing the following code:


Criteria criteria = new Criteria();
criteria.addEqualTo("userid", new Long());
criteria.addEqualTo("primaryLanguage.lookupType", "PREFERRED_LANGUAGE");
ReportQueryByCriteria q = QueryFactory.newReportQuery(Task.class, criteria);
q.setPathOuterJoin("primaryLanguage");
q.setPathOuterJoin("primaryLanguage.lookupType");
q.setColumns(new String[] {"name", "primaryLanguage.meaning"});


Unfortunately, I can't figure out a way to get it to apply the outer-join to
the LOOKUP_TYPE column, as setPathOuterJoin("primaryLanguage.lookupType")
doesn't do anything, and there's no "addLeftJoinEqualTo" or the like.

Ideas?

What I'd LIKE to be able to do is something along the lines of


Lookup:



Task:

  
  



That way the relationship can be declaratively stated in the XML.

Thanks!

-Jim Moore

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



Re: Re: JDO OJB bridge and object states

2003-08-01 Thread Thomas Mahler
> Hello Thomas,
> 
> This might have been my own fault. I fetched the an object within other 
> transaction and tried to set it to another object's field within another 
> transaction  and then tried to persist the container object. This caused 
> a primary key violation because it was already in the database. 

OK!

> All JDO 
> flags (pesistent, dirty, transient) seem to be false even after data has 
> just been fetched from database, which is weird.
> 
> Is this expected behaviour?

No, it's really an issue. there is already a thread regarding this issue on the 
mailinglist.
I'm currently working on a fix for this problem. Objects loaded by OJB should show the 
right flags to user code !

cheers,
Thomas 
> -Marko
> 
> > 
> > I'm not aware of any shortcomings of the JDO stuff.
> > please post a code sample to understand your problem.
> > 
> > If there is a bug we'll have to fix it!
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__
Spam-Filter fuer alle - bester Spam-Schutz laut ComputerBild 15-03
WEB.DE FreeMail - Deutschlands beste E-Mail - http://s.web.de/?mc=021120


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



Conversion on a collection

2003-08-01 Thread Sebastien Cesbron
Hi,

I hope this is my last post for the week :-)
Here are two new problems that I face during my adoption of ojb. I think
 that if I can resolve both of them and the other one of my last post I
can change my mapping layer.
1 - Is it possible to specify a conversion on a collection. There is
nothing about that in the doc. My problem is that I have a n:m relation
between an object (represented by a table in my db) and an enum type
(represented by an Integer column.
Ex :
Class User -> Table User
Enum Role -> Integer on table User_Role
table User
(
  ID integer not null
)
table User_Role
(
  USER_ID integer not null,
  ROLE_ID integer not null,
  foreign key (USER_ID)   references USER(ID)
)
This point is quite important because I don't want to create a Role
table. I want my Role's instances to be unique, I don't want to load one
Role each time I have a link.
2 - Multiple indirections
User has a m:n relation with Profile which has m:n relation with Role. I
want to put a link User -> Role in my object model. Is it possible to
specify such a link that has to go through the tables :
TUSER->TUSER_PROFILE->TPROFILE->TPROFILE_ROLE ?
This point is not really important because if this is not possible I can
 load my profiles and make the user-role link programmaticaly.


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


RE: Query a non navigable path

2003-08-01 Thread Jim Moore
I guess I don't understand the question: That's a very basic 1:n
relationship, exactly what OJB does easily, with a clear "path."

http://db.apache.org/ojb/tutorial3.html#mapping%201:n%20associations

So you XML would look like


  
  
  
  

  
  

  



  
  
  
  

  
  

  



-Original Message-
From: Sebastien Cesbron [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 01, 2003 1:30 PM
To: OJB Users List
Subject: Re: Query a non navigable path


The connexion is that my email have one sender and one receiver. For this
example, the database looks like

create table EMAIL
(
   ID  integer not null,
   SENDER_ID   integer not null,
   RECEIVER_ID integer not null,
   primary key (ID),
   foreign key (SENDER_ID)   references USER(ID),
   foreign key (RECEIVER_ID) references USER(ID)
);

create table USER
(
   ID integer not null,
   primary key (ID)
);

Seb

PS : Sorry if there is syntax erros, I can't cut and paste my sql

Jim Moore wrote:
> Do you have anything that would connect them?  What does your database 
> definition look like for those tables?
> 
> 
> -Original Message-
> From: Sebastien Cesbron [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 01, 2003 1:07 PM
> To: [EMAIL PROTECTED]
> Subject: Query a non navigable path
> 
> 
> Hi,
> 
> I'am always on the way of integrating ojb in my project. It works very
> well but I am in front of a problem I can't solve.
> I have for example this classes :
> Class Email
> {
> private User sender;
> private User receiver;
> }
> Class User
> {
> // No link to the * emails I sent or received
> }
> 
> I am using the PB-API an I want to retrieve a liste of all users that
> were receivers of email I sents. How can I do that ?
> As queries are based on path expressions and I don't have path from 
> receiver I don't know how to do such a query
> 
> Thanks in advance for any help
> 
> Seb

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



RE: 1:1 mapping

2003-08-01 Thread Hal Arnold
Granted, and I will pursue this as a possibility, hopefully we can make
our design work using the parent-child assoc. only. But is
there no way to control the order? I assume that the answer is no
from your response. I guess I'll have to look into how OJB decides
to satisfy my curiosity. Thanks for the quick response,

hba

-Original Message-
From: Thomas Mahler [mailto:[EMAIL PROTECTED]
Sent: Friday, August 01, 2003 5:13 AM
To: OJB Users List
Subject: Re: 1:1 mapping


Hi Hal,

I think the problem is the bidirectional association.
If you would simply use an unidirectional association
OJB will evaluate this association and insert Objects in the correct 
order. If there is a birectional association specified OJB does not know 
which side is the master that must be inserted first!

cheers,
Thomas

hal arnold wrote:
> Folks,
> 
> We have a simple parent-child relationship mapping
> with navigability in both directions (parent has
> association for child and vice-versa), with fk
> references in both repository descriptors pointing to
> the other. Everything seemed to be working (as far as
> autoupdate) except that today, we turned on a
> constraint (Oracle) that says the parent must exist
> when the child is created. It immediately broke the
> unit tests, giving a 'constraint violation', implying
> that the parent was not in existence when the child
> was trying to be created. Sure enuf, looking at the
> emitted sql (p6spy) seems to show that the child gets
> created first. Again, we are simply trying create a
> parent-child relationship, by building the object tree
> and then storing the parent. 
> 
> Is there anyway to force which creation occurs first?
> One would think that it would be natural to think that
> the parent would be created first, or at least that
> you guys would have provided for this constraint; it
> seems so natural.
> 
> thanks in advance,
> 
> hba 
> 
> __
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> -
> 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: Examples of problems with

2003-08-01 Thread Armin Waibel
Hi Adam,

this is not my special subject (concerns Jakob/Thomas),
but if no one else find a solution for your problem I
will integrate your test cases into the test-suite.
Then the gurus can start working on that ;-)

regards,
Armin

- Original Message -
From: "Adam Griffiths" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 01, 2003 5:46 PM
Subject: Examples of problems with 


Hi,

I noticed my attachments in the previous two mails did not seem to work.

I'd be really grateful for any help or suggestions on problems I've been
having with the  mechanism. I
spent
some time putting together the examples of where it goes wrong for me
and
would be very happy if anyone would like to download them and take a
look.

The examples from my first email, regarding abstract classes and the
extent
system can be found at:
http://www.adam-griffiths.co.uk/testOjb1.zip

The examples from my second email regarding the use of separate primary
keys
and foreign keys can be found at:
http://www.adam-griffiths.co.uk/testOjb2.zip

Regards

Adam


s_p_a_m_t_r_a_p   from:[EMAIL PROTECTED]
Do not email the above address or remove these two lines


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



Examples of problems with

2003-08-01 Thread Adam Griffiths
Hi,

I noticed my attachments in the previous two mails did not seem to work.

I'd be really grateful for any help or suggestions on problems I've been
having with the  mechanism. I spent
some time putting together the examples of where it goes wrong for me and
would be very happy if anyone would like to download them and take a look.

The examples from my first email, regarding abstract classes and the extent
system can be found at:
http://www.adam-griffiths.co.uk/testOjb1.zip

The examples from my second email regarding the use of separate primary keys
and foreign keys can be found at:
http://www.adam-griffiths.co.uk/testOjb2.zip

Regards

Adam


s_p_a_m_t_r_a_p   from:[EMAIL PROTECTED]
Do not email the above address or remove these two lines 


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



Another issue with 1.0 rc4 super

2003-08-01 Thread Adam Griffiths
Hi,

I have found another anomaly with the  mechanism. I was following tutorial 3, Advance O/R and the problem I
found was with the part where is says:

"consider the case where B_TABLE contains an additional foreign key column
B_TABLE.A_ID referencing A_TABLE.ID"

This does not seem to work for me and I have put together an example case
where it goes wrong. It's hard to describe without running the example and
seeing for yourself but basically: When B extends A and C extends A, they
all have their own primary keys, and B and C have foreign keys pointing to
table A (which is how it is described in the tutorial), an ojb search on
Ainterface does not return any C objects (which do exist) but does return
the B object twice.

I have attached all the files necessary to replicate this scenario if anyone
is interested, I would certainly be very interested to find out if I am
mistaken or if there is a bug.

Regards
Adam Griffiths

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

Re: Query a non navigable path

2003-08-01 Thread Sebastien Cesbron
The connexion is that my email have one sender and one receiver.
For this example, the database looks like
create table EMAIL
(
  ID  integer not null,
  SENDER_ID   integer not null,
  RECEIVER_ID integer not null,
  primary key (ID),
  foreign key (SENDER_ID)   references USER(ID),
  foreign key (RECEIVER_ID) references USER(ID)
);
create table USER
(
  ID integer not null,
  primary key (ID)
);
Seb

PS : Sorry if there is syntax erros, I can't cut and paste my sql

Jim Moore wrote:
Do you have anything that would connect them?  What does your database
definition look like for those tables?
-Original Message-
From: Sebastien Cesbron [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 01, 2003 1:07 PM
To: [EMAIL PROTECTED]
Subject: Query a non navigable path

Hi,

I'am always on the way of integrating ojb in my project. It works very 
well but I am in front of a problem I can't solve.
I have for example this classes :
Class Email
{
private User sender;
private User receiver;
}
Class User
{
// No link to the * emails I sent or received
}

I am using the PB-API an I want to retrieve a liste of all users that 
were receivers of email I sents. How can I do that ?
As queries are based on path expressions and I don't have path from 
receiver I don't know how to do such a query

Thanks in advance for any help

Seb

-
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: Query a non navigable path

2003-08-01 Thread Jim Moore
Do you have anything that would connect them?  What does your database
definition look like for those tables?


-Original Message-
From: Sebastien Cesbron [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 01, 2003 1:07 PM
To: [EMAIL PROTECTED]
Subject: Query a non navigable path


Hi,

I'am always on the way of integrating ojb in my project. It works very 
well but I am in front of a problem I can't solve.
I have for example this classes :
Class Email
{
private User sender;
private User receiver;
}
Class User
{
// No link to the * emails I sent or received
}

I am using the PB-API an I want to retrieve a liste of all users that 
were receivers of email I sents. How can I do that ?
As queries are based on path expressions and I don't have path from 
receiver I don't know how to do such a query

Thanks in advance for any help

Seb

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



Query a non navigable path

2003-08-01 Thread Sebastien Cesbron
Hi,

I'am always on the way of integrating ojb in my project. It works very 
well but I am in front of a problem I can't solve.
I have for example this classes :
Class Email
{
private User sender;
private User receiver;
}
Class User
{
// No link to the * emails I sent or received
}

I am using the PB-API an I want to retrieve a liste of all users that 
were receivers of email I sents. How can I do that ?
As queries are based on path expressions and I don't have path from 
receiver I don't know how to do such a query

Thanks in advance for any help

Seb

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


rc4 reference-descriptor name="super"

2003-08-01 Thread Adam Griffiths
Hi,
I noticed that 1.0 rc4 is out, (although the front page of the site does not
mention it). It includes the addition of the special 'super' reference
descriptor for mapping classes on multiple joined tables. i.e:
. I very am pleased to find this has
been added, it suits my mapping situation well.

It works fine for the simple cases given in the docs (tutorial3) but I have
two cases where I'm having trouble making it work. The first is when 'super'
is an abstract class and the second is when using 'extents'.

The error I get when the 'super' (test.A in my example) class is abstract
is: 

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR:
PersistenceBrokerException during the execution of materializeObject: Unable
to build object instance (MAYBE you don't have a constructor
available):class test.A: (Could not instantiate test.A: null)

Which makes sense because test.A is abstract and could not be instantiated,
however it never needs to be because only it's subclasses are. It seems that
ojb wants to instantiate it all the same and I wondered if it would make a
good addition to ojb to not attempt to instantiate abstract classes,
specifically so that they can be used .

With extents the problem I encountered was as follows. It is does not work
to have   in the , in this case ojb returns all the A objects,
twice! As I was saying earlier I would like A to be abstract but even when
it's not this still does not make sense to return A objects when really the
rows in table A represent part B objects (by virtue of the fact their
primary key is in table B as a foreign key, and A is 'super' to B). My guess
is that the extent mechanism is designed for mapping all classes on the same
table, it would be great if it also worked for mapping classes on multiple
joined tables.

I'd be very grateful if someone could let me know if I'm misunderstanding
anything here, or if I'm encountering a bug / missing feature of the latest
OJB.

Many Thanks
Adam

I have attached a zip file with all the necessary java, settings files, and
sql script to set up the test cases that I used. If you want to play around
it should be fairly simple to use them.


s_p_a_m_t_r_a_p   from:[EMAIL PROTECTED]
Do not email the above address or remove these two lines 

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

Re: JDO OJB bridge and object states

2003-08-01 Thread Marko Lahma
Hello Thomas,

This might have been my own fault. I fetched the an object within other 
transaction and tried to set it to another object's field within another 
transaction  and then tried to persist the container object. This caused 
a primary key violation because it was already in the database. All JDO 
flags (pesistent, dirty, transient) seem to be false even after data has 
just been fetched from database, which is weird.

Is this expected behaviour?

-Marko

I'm not aware of any shortcomings of the JDO stuff.
please post a code sample to understand your problem.
If there is a bug we'll have to fix it!




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


Re: Why foreignkey field-ref and not column-ref ?

2003-08-01 Thread Thomas Mahler
Hi Sebastien,

It's possible to use anonymous fields for foreign keys. an anonymous 
field does not specify a java attribute, only a column in the db.
See:
http://db.apache.org/ojb/howto-use-anonymous-keys.html

cheers,
Thomas
Sebastien Cesbron wrote:
Hi,

I want to specify a relation between an object A (table T_A) and one 
object B (table T_B) with a foreignkey on the column idB of the table T_A.
To do that I have to create an attribute idB in the class A and to put a 
  in my  tag.
Why it is not possible to act as in the "non decomposed m:n mapping" and 
specify a db column in stead of a class attribute.
For example I would like to write  where 
idB is a column of T_B. With this version, I don't have to put an 
artificial idB attribute in my class A.

Is it something difficult to do or is it an implementation choice ?

Thanx

Seb

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


Why foreignkey field-ref and not column-ref ?

2003-08-01 Thread Sebastien Cesbron
Hi,

I want to specify a relation between an object A (table T_A) and one 
object B (table T_B) with a foreignkey on the column idB of the table T_A.
To do that I have to create an attribute idB in the class A and to put a 
  in my  tag.
Why it is not possible to act as in the "non decomposed m:n mapping" and 
specify a db column in stead of a class attribute.
For example I would like to write  where 
idB is a column of T_B. With this version, I don't have to put an 
artificial idB attribute in my class A.

Is it something difficult to do or is it an implementation choice ?

Thanx

Seb

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


What is wrong with this ODMG collection ?

2003-08-01 Thread Thomas Dudziak
For whatever reason I'm not able to get collections working with
ODMG. I'vd attached a simple demonstration which always throws the runtime
exception at the end of the Main.testCollection method (I'm using default
settings in the database descriptor with the MySQL profile).
Could please somebody point out my error ?

Thanks in advance,
Tom



src.zip
Description: Zip archive
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: JDO - Objects fetched from DB are in transient state, not persistent

2003-08-01 Thread Thomas Mahler
Hi Ketan,

Ketan Gangatirkar wrote:
Thomas,

I've been stepping through the OBJ JDO and JDORI code.  I have 
determined that the PersistenceCapable objects never are assigned a 
StateManager (member jdoStateManager) when they are assembled from a row 
result.
That's exactly the problem! I'm currently researching how to solve this 
issue.

 When an object is created and persisted, it does get assigned a 
StateManager, but I see no corresponding assignment for objects fetched 
from the DB.  
I does does happen when objects are retrieved by Identity in 
OjbStoreManager.fetch.

But it does not happen when loading object via a query or a whole Extent.

I'm currently trying to implement the StateManager assignment  in 
OjbExtent too. But it's not as easy as I hoped...

I'll need a closer look at the JDORI again...

cheers,
Thomas
At what point should that be happening?

Thomas Mahler wrote:

Hi Ketan,

Ketan Gangatirkar wrote:

All,

I'm having a problem with objects fetched from the database.  All JDOs
are treated as Transient objects when they have just been fetched from
the database.  Thus, they don't have object ids (.jdoGetObjectId()
returns null) or a reference to a PM (.jdoGetPersistenceManager()
returns null).  obj.jdoIsPersistent() and JDOHelper.isPersistent(obj)
both return false (obviously, since they're the same).  As a result,
when I setX() on the objects, the PM does not propagate the changes back
to the database even though the object was just loaded from the
database.


Ah, this seems similar to the problem Marko Lahma reported yesterday.

  I have one test JSP like this (slightly condensed):

Iterator iterator = pm.getExtent(User.class, false).iterator();
while (iterator.hasNext())
{
 User user = (User) iterator.next();
 boolean b = JDOHelper.isPersistent(user));
//  
}
b is almost always false.  Only when user is a newly or recently created
object will it be in the Persistent state.  I can fetch it using Extents
or Queries and isPersistent() returns true in that case.  At some point,
however, recently inserted objects stop being retrieved as persistent
objects and become like the others.  I have not been able to discern a
cause; they seem to "expire" after a few minutes.  Restarting Tomcat
will definitely cause retrieved objects to be treated as transient.  I
am using "application" type persistence, but from what I could gather
from the documentation, that is supported without any special programmer
support.
I have seen several mentions in the list archives for this list of
similar problems, but no resolution.  Given that the JDO implementation
would be practically useless without being able to update persistent
JDOs, I am certain that this is user error, but after spending a whole
day trying to track this down, I am out of ideas.  I would greatly
appreciate a pointer in the right direction.


 From what you describe I assume it is a bug. I'll try to fix it asap.

cheers,
Thomas
More details:

As far as configuration goes, I am using default OBJ.properties
settings.  I have verified my repository_user.xml and *.jdo files.  I am
not using any of the internal tables because I am not using any of the
features for which it is required.
Software packages I am using:

DB-OJB 1.0 RC3 (could not build RC4)

Tomcat 4.1.something (WinXP)
JDK 1.4.2 (WinXP)
J2EE 1.3.1 (WinXP)
PostgreSQL 7.3.3 (on FreeBSD)
Things I have tried:

Defining my own object id class

Using a single, static instance of PersistenceManager instead of going
to PersistenceManagerFactory multiple times
Fiddling with the location of the queries in the transaction

Obtaining JDOs via Extents vs. Queries

forcing cache reloads with evict() and refresh()

-
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: 1:1 mapping

2003-08-01 Thread Thomas Mahler
Hi Hal,

I think the problem is the bidirectional association.
If you would simply use an unidirectional association
OJB will evaluate this association and insert Objects in the correct 
order. If there is a birectional association specified OJB does not know 
which side is the master that must be inserted first!

cheers,
Thomas
hal arnold wrote:
Folks,

We have a simple parent-child relationship mapping
with navigability in both directions (parent has
association for child and vice-versa), with fk
references in both repository descriptors pointing to
the other. Everything seemed to be working (as far as
autoupdate) except that today, we turned on a
constraint (Oracle) that says the parent must exist
when the child is created. It immediately broke the
unit tests, giving a 'constraint violation', implying
that the parent was not in existence when the child
was trying to be created. Sure enuf, looking at the
emitted sql (p6spy) seems to show that the child gets
created first. Again, we are simply trying create a
parent-child relationship, by building the object tree
and then storing the parent. 

Is there anyway to force which creation occurs first?
One would think that it would be natural to think that
the parent would be created first, or at least that
you guys would have provided for this constraint; it
seems so natural.
thanks in advance,

hba 

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
-
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 bug: Using a String field as OID

2003-08-01 Thread Thomas Mahler
Hi Vijay,

The enhancing is done by the SUN JDORI Reference enhance and not by any 
OJB component.
I have heared of such problems before, but I feel there is little that 
the OJB team can do on this issue.

I think you should report the problem to the JDORI team at SUN.

cheers,
Thomas
Vijay Balasubramanian wrote:
Hi All,
I am not sure if it is already reported.  Anyway,
if i have a bean with a field "int id" in my bean which is not
a primary key(i have another string field configured as a
primary key in .jdo), OJB is taking int id 
as a primary field during enhancing. 

Note: I do not have this id field in PhaseActivityBean.jdo

It is causing nullPointerexception during updates.

public class PhaseActivityBean implements java.io.Serializable
{
private String phaseActivity; // Primary Key
private String description;
// Causes npe with the following field declared in the bean
//private int id;

public PhaseActivityBean(  )
{
}
public String getPhaseActivity(  )
{
return phaseActivity;
}

public void setPhaseActivity( String phaseActivity )
{
this.phaseActivity = phaseActivity;
}

public String getDescription(  )
{
return description;
}

public void setDescription( String description )
{
this.description = description;
}

}
Thanks,
Vijay B



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


Re: Mapping inheritence

2003-08-01 Thread Thomas Mahler
Hi Sebastien,

Leandros patch is in RC4 already.

cheers,
Thomas
Sebastien Cesbron wrote:
Hi,

I'am new to OJB and I am looking at the archive to have some info.
I've seen that supporting inheritence of descriptors in mapping 
repository is on the way  :am I wrong ?
If this is true, what is the status of this functionality ? In the june 
posts leandro said that he did a patch. Do I have to find this patch or 
is it sufficient for me if I take the last nightly build ?

Thanx in advance

Seb

-
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: auto-* settings and ODMG

2003-08-01 Thread Thomas Mahler
Hi again Thomas

Thomas Dudziak wrote:
Could you please elaborate this a bit further ? Does that mean that if I 
have a reference or collection to/with some other ojb-persistent class 
then these objects will be written automatically (i.e. intrinsic 
auto-update=true) ?
exactly! We have to implement it in this way as ODMG claims to provide 
"persistence by reachability".
That is if a root object is registered to a transaction all associated 
objects become persistent as well.

cheers,
thomas
Thanks,
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]


1:1 mapping

2003-08-01 Thread hal arnold
Folks,

We have a simple parent-child relationship mapping
with navigability in both directions (parent has
association for child and vice-versa), with fk
references in both repository descriptors pointing to
the other. Everything seemed to be working (as far as
autoupdate) except that today, we turned on a
constraint (Oracle) that says the parent must exist
when the child is created. It immediately broke the
unit tests, giving a 'constraint violation', implying
that the parent was not in existence when the child
was trying to be created. Sure enuf, looking at the
emitted sql (p6spy) seems to show that the child gets
created first. Again, we are simply trying create a
parent-child relationship, by building the object tree
and then storing the parent. 

Is there anyway to force which creation occurs first?
One would think that it would be natural to think that
the parent would be created first, or at least that
you guys would have provided for this constraint; it
seems so natural.

thanks in advance,

hba 

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Re: JDO - Objects fetched from DB are in transient state, not persistent

2003-08-01 Thread Ketan Gangatirkar
Thomas,

I've been stepping through the OBJ JDO and JDORI code.  I have 
determined that the PersistenceCapable objects never are assigned a 
StateManager (member jdoStateManager) when they are assembled from a row 
result.  When an object is created and persisted, it does get assigned a 
StateManager, but I see no corresponding assignment for objects fetched 
from the DB.  At what point should that be happening?

Thomas Mahler wrote:

Hi Ketan,

Ketan Gangatirkar wrote:

All,

I'm having a problem with objects fetched from the database.  All JDOs
are treated as Transient objects when they have just been fetched from
the database.  Thus, they don't have object ids (.jdoGetObjectId()
returns null) or a reference to a PM (.jdoGetPersistenceManager()
returns null).  obj.jdoIsPersistent() and JDOHelper.isPersistent(obj)
both return false (obviously, since they're the same).  As a result,
when I setX() on the objects, the PM does not propagate the changes back
to the database even though the object was just loaded from the
database.


Ah, this seems similar to the problem Marko Lahma reported yesterday.

  I have one test JSP like this (slightly condensed):

Iterator iterator = pm.getExtent(User.class, false).iterator();
while (iterator.hasNext())
{
 User user = (User) iterator.next();
 boolean b = JDOHelper.isPersistent(user));
//  
}
b is almost always false.  Only when user is a newly or recently created
object will it be in the Persistent state.  I can fetch it using Extents
or Queries and isPersistent() returns true in that case.  At some point,
however, recently inserted objects stop being retrieved as persistent
objects and become like the others.  I have not been able to discern a
cause; they seem to "expire" after a few minutes.  Restarting Tomcat
will definitely cause retrieved objects to be treated as transient.  I
am using "application" type persistence, but from what I could gather
from the documentation, that is supported without any special programmer
support.
I have seen several mentions in the list archives for this list of
similar problems, but no resolution.  Given that the JDO implementation
would be practically useless without being able to update persistent
JDOs, I am certain that this is user error, but after spending a whole
day trying to track this down, I am out of ideas.  I would greatly
appreciate a pointer in the right direction.


 From what you describe I assume it is a bug. I'll try to fix it asap.

cheers,
Thomas
More details:

As far as configuration goes, I am using default OBJ.properties
settings.  I have verified my repository_user.xml and *.jdo files.  I am
not using any of the internal tables because I am not using any of the
features for which it is required.
Software packages I am using:

DB-OJB 1.0 RC3 (could not build RC4)

Tomcat 4.1.something (WinXP)
JDK 1.4.2 (WinXP)
J2EE 1.3.1 (WinXP)
PostgreSQL 7.3.3 (on FreeBSD)
Things I have tried:

Defining my own object id class

Using a single, static instance of PersistenceManager instead of going
to PersistenceManagerFactory multiple times
Fiddling with the location of the queries in the transaction

Obtaining JDOs via Extents vs. Queries

forcing cache reloads with evict() and refresh()

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


nested query and polymorphism

2003-08-01 Thread oliver . matz
Hello,

I am using OJB current CVS.  

Consider the data model from the junit tests: 
Zoo has a 1-n relation to InterfaceAnimal, which has two
concrete Subclasses Mammal and Reptile.

I want to execute a query for all Zoos that have an animal
named "xxx", and I want to use nested queries.
(I know that in this special case 
I could do Criteria.addEqual("animals.name", "xxx"),
but I will need a more complex subquery later.)

This results in the appended stacktrace.

Appended you find a junit test to reproduce the problem.

Could you please tell me the intended behaviour?
Is such a query supposed to work?

Thank you,
Olli

- snip
--
1)
testQuery(org.apache.ojb.broker.NestedQueryTest)java.lang.NullPointerExcepti
on
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias.hashCode(
SqlQueryStatement.java:1635)
at java.util.HashMap.hash(HashMap.java:257)
at java.util.HashMap.put(HashMap.java:375)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(SqlQue
ryStatement.java:1348)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.(SqlQueryState
ment.java:120)
at
org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.(SqlSelectSta
tement.java:86)
at
org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPreparedSel
ectStatement(SqlGeneratorDefaultImpl.java:177)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSubQuery(SqlQu
eryStatement.java:716)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendParameter(SqlQ
ueryStatement.java:701)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendInCriteria(Sql
QueryStatement.java:562)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendCriteria(SqlQu
eryStatement.java:630)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSQLClause(SqlQ
ueryStatement.java:680)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.asSQLStatement(SqlQu
eryStatement.java:466)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendClause(SqlQuer
yStatement.java:402)
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendWhereClause(Sq
lQueryStatement.java:360)
at
org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement(SqlSel
ectStatement.java:253)
at
org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPreparedSel
ectStatement(SqlGeneratorDefaultImpl.java:178)
at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl
.java:265)
at
org.apache.ojb.broker.accesslayer.RsIterator.(RsIterator.java:199)
at
org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIterator
FactoryImpl.java:95)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Pers
istenceBrokerImpl.java:2380)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Persis
tenceBrokerImpl.java:1716)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1343)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1515)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1551)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1540)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:317)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:317)
at
org.apache.ojb.broker.NestedQueryTest.testQuery(NestedQueryTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
rethrown as org.apache.ojb.broker.PersistenceBrokerException
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1522)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1551)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1540)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:317)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(
DelegatingPersistenceBroker.java:317)
at
org.apache.ojb.broker.NestedQueryTest.testQuery(NestedQueryTest.java:50)

Re: Problem: autoincrement can break 1:1 relation

2003-08-01 Thread shivaken
Hi Armin, thanks for your response.

> thanks for the patch. Please, can you send me a patch for
> SequenceManagerNativeImpl (see CVS) too. Because
> I don't want to support SequenceManagerMySQLImpl
> any longer (to check your patch you can find a simple test case
> called NativeIdentifierTest). thanks.

Ok. I attached the patch for SequenceManagerNativeImpl.

Though I'm very suprised about you don't want to support 
SequenceManagerMySQLImpl.
I don't like SequenceManagerNativeImpl because 
SequenceManagerNativeImpl.getUniqueLong returns -1.
I really don't like that. And MySQL dosen't work properly with -1.

I want SequenceManagerNativeImpl to support init property to define
this value. That can be 0 or -1. And it must be depend on DB type.

Yesterday, I found another bug in SequenceManagerMySQLImpl.
MySQL returns long array SELECT LAST_INSERT_ID() query,
so getting new id takes long time when table has many records.
Just adding ' LIMIT 1 '  at the end fixes this performance problem.

regards,

-- shivaken
antshell: Ant command line front end
http://www.antshell.org
--- SequenceManagerNativeImpl.java.orig	2003-08-01 11:52:00.0 +0900
+++ SequenceManagerNativeImpl.java	2003-08-01 17:11:04.0 +0900
@@ -141,8 +141,15 @@
 public void afterStore(JdbcAccess dbAccess, ClassDescriptor cld, Object obj) throws SequenceManagerException
 {
 FieldDescriptor fd = cld.getAutoIncrementField();
-long newId = getLastInsert(dbAccess, cld);
-setFieldValue(obj, fd, new Long(newId));
+if ((fd != null) && (isAutoIncremented(obj, fd)))
+{  
+long newId = getLastInsert(dbAccess, cld);
+setFieldValue(obj, fd, new Long(newId));
+}
+}
+
+private boolean isAutoIncremented(Object obj, FieldDescriptor fd) throws SequenceManagerException { 
+return fd.getPersistentField().get(obj).equals(getUniqueValue(fd));
 }
 
 

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

Re: OJB hanging

2003-08-01 Thread Armin Waibel
Hi Julian,

did you tried without using BeanUtils in
your persistent object toString() method?
Does OJB hanging nevertheless?

regards,
Armin

- Original Message -
From: "Julian Exenberger" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; "Armin Waibel"
<[EMAIL PROTECTED]>
Sent: Friday, August 01, 2003 6:44 AM
Subject: RE: OJB hanging


Hi Armin,

I am using "org.apache.ojb.broker.util.logging.PoorMansLoggerImpl" for
development.

I have overridden toString() in the object to use BeanUtils.describe()
in the apache commons BeanUtils package.

Perhaps BeanUtils attempts to synchronize the object when it's already
locked by the safeDebug() method.

Regards,
Julian


-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: 01 August 2003 02:04
To: OJB Users List
Subject: Re: OJB hanging

Hi Julian,

> "logger.safeDebug("executeInsert",obj);" is called (line 193).
> I can only assume that the safe debug is causing a thread deadlock

hmm, really strange!
On the given persistent object obj.toString() was called,
could this be the problem?
Which logging implementation in OJB.properties do you use?

regards,
Armin

- Original Message -
From: "Julian Exenberger" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; "Armin Waibel"
<[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 1:37 PM
Subject: RE: OJB hanging


Hi Armin,

I have actually been analyzing it deeper it occurs in
org.apache.ojb.broker.accesslayer.JdbcAccessImpl class in the
executeInsert() method when the line
"logger.safeDebug("executeInsert",obj);" is called (line 193).

I can only assume that the safe debug is causing a thread deadlock (it
event makes the eclipse debugger go moggy).

I turned my logging back to info and not it works fine.

For background info I am using OJB from within Tomcat and the sample
code is

try
{
if ((db == null) ||
  (!(db.isInTransaction()))||
  (delegate = null) )
startOJB();
if (delegate == null)
db.store(object);
else
delegate.add(object);
}
catch (Exception e)
{
logger.error(e.getMessage());
throw createExceptionWithMessageHolder(e);
}
finally
{
if ((db != null)&&(!db.isInTransaction()))
releaseOJB();
}

Let me know if you need more info

Regards,
Julian



-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: 31 July 2003 01:29
To: OJB Users List
Subject: Re: OJB hanging

Hi Julian,

can you post more info?
do you use OJB standalone?- used environment?
do you tried run your test code in standalone OJB?
code snip of your test code.

regards,
Armin

- Original Message -
From: "Julian Exenberger" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 30, 2003 6:23 PM
Subject: OJB hanging


Hi,

I am doing a 1:m insert of an object. When I step through the code using
the debugger it works fine, however if I just let it run normally OJB
hangs

This is how my repository.xml looks

























For reference I am using RC4

Could anybody tell me what is wrong

thanks


Julian Exenberger
-
J2EE Developer
Tel :  +27 11 340 7210
Fax : +27 11 340 7342
Cell:  +27 82 493 3352
E-Mail : [EMAIL PROTECTED] 
-
M-WEB BUSINESS SOLUTIONS

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com






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



OQL FROM with multiple objects

2003-08-01 Thread hurle
Hi!
Is it possible with OJB to use a from with multiple objects like:

select p.name, o.name from Person p, p.office o

If yes, what is the correct syntax? I tried it like written above and 
with "... from Person as p ..." but it didn't work.

Is a query with multiple and not associated objects possible?
example:

select p.name, o.name from Person p, Office o where o.address = p.address

If yes, what objects would I receive?

Thanks!
   Florian

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


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



Mapping inheritence

2003-08-01 Thread Sebastien Cesbron
Hi,

I'am new to OJB and I am looking at the archive to have some info.
I've seen that supporting inheritence of descriptors in mapping 
repository is on the way  :am I wrong ?
If this is true, what is the status of this functionality ? In the june 
posts leandro said that he did a patch. Do I have to find this patch or 
is it sufficient for me if I take the last nightly build ?

Thanx in advance

Seb

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


1-1 association & mapping each class on a distinct table

2003-08-01 Thread Peter Rajsky
hello,
we would like to implement following 1-1 association:
1) class A references class B [A->B]
2) class B has 2 subclasses B1 and B2. B1 and B2 are mapped on distinct
tables [t_b1 and t_b2].

3) we don't have any synthetic OID, which contains
class name - so values of our primary key attribute are not unique across
the
tables t_b1, t_b2... we can't change it now [application is deployed and
working] :(
4) (3) implies that we cannot use simple foreignkey reference descriptor,
because
we should also define, which class is referenced... so our table a should
have two columns: b_id, b_class. column b_class defines the class of
referenced
object [i know, it is not very nice from relational point of view, because
b_id
is not real foreign key...].

is it possible to implement it in OJB? [or is it stupid requirement?]

thanks a lot.

pr

note:
solution would be to create 2 subclasses of A: AreferencingB1 and
AreferencingB2 and to
map them to one table. this solution has some other problems... but we can
use it, if there
is no other solution.






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