Re: Queries for M:N collections?

2003-10-28 Thread Rémi Bars
Hi all, i found my bug !

it is in my p6spy library (a bug in the log module, this bug is referenced
in bugzilla)

Remi

- Original Message - 
From: "Rémi Bars" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 27, 2003 5:10 PM
Subject: Queries for M:N collections?


> Hi all,
>
> i m trying to store an object A wich have a list of A element, when i try
> that it works first time and after i got this exception
>
> org.apache.ojb.broker.PersistenceBrokerException:
> java.lang.StringIndexOutOfBoundsException: String index out of range: -2
>  at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getMtoNImplementor(Persiste
> nceBrokerImpl.java:921)
>  at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Persistenc
> eBrokerImpl.java:783)
>  at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBroker
> Impl.java:2007)
>  t
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
> .java:1889)
>  at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
> .java:1851)
>  at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
> Source)
>  at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
> Source)
>  at org.apache.ojb.odmg.states.StateOldDirty.commit(Unknown Source)
>  at org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(Unknown
> Source)
>  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)
>
> create table A(id int primary key not null)
>
> create table A_A(ParentID int not null, ID int not null,primary key
> (ParentID , ID))
>
>
>
> 
> name="id"
> column="id"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"
>  />
>
>  name="listOfA"
>element-class-ref="A"
>auto-retrieve="true"
>auto-update="true"
>auto-delete="false"
>indirection-table="A_A"
>  >
>
>
>  
>
>  
>
>
> -
> 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]



Queries for M:N collections?

2003-10-27 Thread Rémi Bars
Hi all,

i m trying to store an object A wich have a list of A element, when i try
that it works first time and after i got this exception

org.apache.ojb.broker.PersistenceBrokerException:
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
 at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getMtoNImplementor(Persiste
nceBrokerImpl.java:921)
 at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Persistenc
eBrokerImpl.java:783)
 at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBroker
Impl.java:2007)
 t
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
.java:1889)
 at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl
.java:1851)
 at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
 at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
 at org.apache.ojb.odmg.states.StateOldDirty.commit(Unknown Source)
 at org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(Unknown
Source)
 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)

create table A(id int primary key not null)

create table A_A(ParentID int not null, ID int not null,primary key
(ParentID , ID))




   

 
   
   
 

 


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



Re: Queries for M:N collections?

2003-10-04 Thread Joe Germuska
At 11:11 +0200 10/2/03, LAURENT Stephane wrote:
you can getCollection of A where listOfA contain at lesat one 
element equal to wantedAInstance :

crit.addEqual("listOfA",wantedAInstance);
getCollectionbyCriteria(A.class,crit);
you can getCollection of A where listOfA contain at lesat one 
element A having at least A in his listOfA collection :

crit.addEqual("listOfA.listOfA",wantedAInstance);
getCollectionbyCriteria(A.class,crit);
Yes, this is it.  To be honest, I went ahead and tried what seemed 
like the intuitive syntax before I saw your reply, and I was pleased 
to see it work.  Knowing now that it works, I can understand the 
approach the framework takes to building the SQL, but I was hung up 
on trying to imagine more pure property access.  That is, in my case, 
my query is something like this:

crit.addIn("items.categoryCode", categories)

Since "items" is a list, obviously it doesn't have a property 
"categoryCode".  Its members have that category, but at first I 
thought I would at least need to somehow specify an index -- i 
thought it might be something like
crit.addIn("items[*].categoryCode", categories)

Of course, now I see that OJB knows that "items" is a collection, not 
a field, and so it can interpret what comes after items 
(.categoryCode) differently than it would in a 1:1 join.

Thanks for your reply,
Joe
--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
 "We want beef in dessert if we can get it there."
  -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association

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


Re: Queries for M:N collections?

2003-10-04 Thread Roland Kruggel
Am Donnerstag Oktober 2 2003 11:11 schrieb LAURENT Stephane:
> Hi,
> I'm not sur to understand, but ...
> you have :
> Class A
> {
> Integer idA;
> String attribute1_A;
> String attribute2_A;
> ..
> Collection listOfA
> }
>
>
> if your repository is like this :
> 
>  primarykey="true" autoincrement="true"/>  name="attribute1_A" column="a1" jdbc-type="VARCHAR"/>
>  jdbc-type="VARCHAR"/> ..
>  auto-retrieve="true" auto-update="true" indirection-table="tableA_A">
> 
> 
>
>   
>
>
> you can getCollection of A where listOfA contain at lesat one element
> equal to wantedAInstance :
>
> crit.addEqual("listOfA",wantedAInstance);
> getCollectionbyCriteria(A.class,crit);
>
> you can getCollection of A where listOfA contain at lesat one element
> A having at least A in his listOfA collection :
>
> crit.addEqual("listOfA.listOfA",wantedAInstance);
> getCollectionbyCriteria(A.class,crit);
>
> ..
>
> is it your goal ?
>   - Original Message -
>   From: Joe Germuska
>   To: OJB Users List
>   Sent: Thursday, October 02, 2003 12:00 AM
>   Subject: Queries for M:N collections?
>
>   At 16:44 -0500 10/1/03, Joe Germuska wrote:
>   >I'm dealing with a case where I want to model an M:N relationship
>   >between two objects of the same type.  I have a collection
>   >descriptor modeled off of the example for this on the OJB site.
>   >When I go to store, I'm getting a class cast exception...
>
>   For what it's worth, changing that property to a Collection
>   definitely solved my problem.  Which leads me to the real question:
>
>   I need to construct a Query which selects collections for either
>   direction of this relationship.  That is, Given a parent, I need to
>   find all of its children, and given a child, I need to find all of
>   their possible parents.
>
>   I can probably work this out with a QueryBySQL, but I'm trying to
>   avoid that.  I don't see any methods on Criteria to set where I can
>   set something like "property contains some member"...  Can anyone
>   advise?
>
>   Thanks in advance,
>   Joe
>
>   --
>   Joe Germuska
>   [EMAIL PROTECTED]
>   http://blog.germuska.com
> "We want beef in dessert if we can get it there."
>  -- Betty Hogan, Director of New Product Development, National
>   Cattlemen's Beef Association
>
>
>  
> -
> 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.522 / Virus Database: 320 - Release Date: 01/10/2003

cu

-- 
Roland Kruggel  mailto: [EMAIL PROTECTED]
System: AMD 1200Mhz, Debian woody, 2.4.20, KDE 3.1.4


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



Re: Queries for M:N collections?

2003-10-03 Thread LAURENT Stephane
Hi,
I'm not sur to understand, but ...
you have :
Class A
{
Integer idA;
String attribute1_A;
String attribute2_A;
...
Collection listOfA
}


if your repository is like this :




...



   
  


you can getCollection of A where listOfA contain at lesat one element equal to 
wantedAInstance :

crit.addEqual("listOfA",wantedAInstance);
getCollectionbyCriteria(A.class,crit);

you can getCollection of A where listOfA contain at lesat one element A having at 
least A in his listOfA collection :

crit.addEqual("listOfA.listOfA",wantedAInstance);
getCollectionbyCriteria(A.class,crit);

...

is it your goal ?
  - Original Message - 
  From: Joe Germuska 
  To: OJB Users List 
  Sent: Thursday, October 02, 2003 12:00 AM
  Subject: Queries for M:N collections?


  At 16:44 -0500 10/1/03, Joe Germuska wrote:
  >I'm dealing with a case where I want to model an M:N relationship 
  >between two objects of the same type.  I have a collection 
  >descriptor modeled off of the example for this on the OJB site. 
  >When I go to store, I'm getting a class cast exception...

  For what it's worth, changing that property to a Collection 
  definitely solved my problem.  Which leads me to the real question:

  I need to construct a Query which selects collections for either 
  direction of this relationship.  That is, Given a parent, I need to 
  find all of its children, and given a child, I need to find all of 
  their possible parents.

  I can probably work this out with a QueryBySQL, but I'm trying to 
  avoid that.  I don't see any methods on Criteria to set where I can 
  set something like "property contains some member"...  Can anyone 
  advise?

  Thanks in advance,
  Joe

  -- 
  Joe Germuska
  [EMAIL PROTECTED]  
  http://blog.germuska.com
"We want beef in dessert if we can get it there."
 -- Betty Hogan, Director of New Product Development, National 
  Cattlemen's Beef Association


  -
  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.522 / Virus Database: 320 - Release Date: 01/10/2003

Queries for M:N collections?

2003-10-01 Thread Joe Germuska
At 16:44 -0500 10/1/03, Joe Germuska wrote:
I'm dealing with a case where I want to model an M:N relationship 
between two objects of the same type.  I have a collection 
descriptor modeled off of the example for this on the OJB site. 
When I go to store, I'm getting a class cast exception...
For what it's worth, changing that property to a Collection 
definitely solved my problem.  Which leads me to the real question:

I need to construct a Query which selects collections for either 
direction of this relationship.  That is, Given a parent, I need to 
find all of its children, and given a child, I need to find all of 
their possible parents.

I can probably work this out with a QueryBySQL, but I'm trying to 
avoid that.  I don't see any methods on Criteria to set where I can 
set something like "property contains some member"...  Can anyone 
advise?

Thanks in advance,
Joe
--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
 "We want beef in dessert if we can get it there."
  -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association

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