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

2004-01-05 Thread Patrick Scheuerer
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]


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

2004-01-05 Thread Patrick Scheuerer
Coup, Robert Muir wrote:

Hi,

Did you see my response to your other post? Please reply to the list.
No I didn't, sorry! I somehow gave up on this post...

Idea #2:
How about:
class-descriptor class=SupportItemI
  extent-class class-ref=Document/
  extent-class class-ref=Download/
/class-descriptor
class-descriptor class=pal_model table=t_pal_model
  ... Field Descriptors ...
  collection descriptor name=collectionOfSupportItemIs
	element-class-ref=SupportItemI
	indirection-table=t_pal_model_supportitems
	
	fk-pointing-to-this-class column=model_id/
	fk-pointing-to-element-class column=SupportItemID/
  /collection-descriptor
/class-descriptor 

class-descriptor class=download table=t_download
  ... Field Descriptors ...
  collection-descriptor name=models
element-class-ref=pal_model
indirection-table=t_download_pal_model

fk-pointing-to-this-class column=SupportItemID/
fk-pointing-to-element-class column=model_id/
  /collection-descriptor
/class-descriptor
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 :)
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) 
and t_pal_model has a 1:n mapping to t_pal_model_supportitemI... is that correct?

Thank you very much for your detailed examples!

Patrick

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


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

2004-01-05 Thread Patrick Scheuerer
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 ;-)

I will let you know how I get along. Thanks again!

Patrick

-
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 Patrick Scheuerer
Coup, Robert Muir wrote:

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 ***
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.

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

I'm going through your answer now...

Patrick

-
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 Patrick Scheuerer
... 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]


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

2004-01-05 Thread Patrick Scheuerer
Thank you very much for your time and effort Robert!

I'm trying to get your solution to work now (keep your fingers crossed! :-) )

Since this is all for my thesis paper you will get an honorable mention in the 
acknowledgment section :-)

Thanks again and I'll let you know If it works!

Take care, Patrick

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


Re: Desperately need help with my repository

2004-01-03 Thread Patrick Scheuerer
Luis Cruz wrote:
Is it possible for you to post the snip of code that does the query? My
guess is that you're doing something like this:
Here's one of my DAO methods in which the Exception is thrown:

public Collection findAllCategories() throws DataAccessException {
PersistenceBroker broker = null;
Collection results = null;
QueryByCriteria query = new QueryByCriteria(CategoryVO.class, null);
query.setStartAtIndex(1);
try {
broker = ServiceLocator.getInstance().findBroker();

results = broker.getCollectionByQuery(query);
} catch (ServiceLocatorException e) {
throw new DataAccessException(Bla Bla, e);
} finally {
if (broker != null) {
broker.close();
}
}

return results;
}
Another one that doesn't work is this ( I followed an example in the book 
Professional Struts Applications):

public Collection findLatestAdditions() throws DataAccessException {

PersistenceBroker broker = null;
Collection results = new Vector();
Criteria criteria = new Criteria();
criteria.addOrderByDescending(id);
Query query = QueryFactory.newQuery(DocumentVO.class, criteria);

query.setStartAtIndex(1);
query.setEndAtIndex(MAXIMUM_LATESTADDITIONS - 1);
try {
broker = ServiceLocator.getInstance().findBroker();
results = (Collection) broker.getCollectionByQuery(query);
} catch (ServiceLocatorException e) {

} finally {
if (broker != null) {
broker.close();
}
}

return results;
}
Criteria criteria = new Critetia();
criteria.addEqualTo(size, someValue);
Query query = new QueryByCriteria(classToQuery, criteria);
Collection result = pb.getCollectionByQuery(query);
No i'm not. And that's the strange thing. I'm not running any query on the size 
of a download.
Maybe the exception is thrown because DocumentVO doesn't have the _fileSize 
attribute but it also implements the SupportItemI Interface as does DownloadVO 
which has this attribute But if that was true queries on Interfaces wouldn't 
be very useful, right?

If so then the problem is that OJB queries are done against objects, not
tables, there for you should change size to _fileSize or to the
corresponding bean method name (depending on the value of
PersistentFieldClass you defined in your OJB.properties file).
The PersistenceFieldClass is
org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl (default)
Hope this helps,
Luis Cruz
Thanks for your tips Luis! Any further ideas would be highly appreciated.
Patrick
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Desperately need help with my repository

2004-01-02 Thread Patrick Scheuerer
Hi everyone,

I'm loosing my mind I just can't figure out what i'm doing wrong. Can some 
of you please take a look at my code / config and tell me what i'm doing wrong?
I know it's a long posting and I would really appreciate it very much if 
somebody could help me out.

I have 7 value objects: DocumentVO, DownloadVO, CategoryVO, UserVO, RoleVO, 
PalModelVO and KeywordVO. They all extend the abstract ValueObject class. 
DownloadVO and DocumentVO implement the SupportItemI Interface.

Here are the individual classes:

public abstract class ValueObject implements Serializable {
}
public interface SupportItemI extends Serializable {

public Long getId();
public void setId(Long id);

public String getName();
public void setName(String name);

public String getDescription();
public void setDescription(String description);

public String getVersion();
public void setVersion(String version);

public Date getCreationDate();
public void setCreationDate(Date date);

public CategoryVO getCategory();
public void setCategory(String category);

public RoleVO getRole();
public void setRole(String role);

public File getFile();
public void setFile(String file);

public void setKeywords(String keywords);
}
public class CategoryVO extends ValueObject implements Serializable {
private Long _id;
private String _name;
private String _description;
private String _path;
private Collection _allItemsOfCategory;
}
public class DocumentVO extends ValueObject implements SupportItemI, Serializable {
private Long _id;
private String _name;
private String _description;
private String _version;
private byte[] _abstract;
private Date _creationDate;
private Long _categoryId;
private CategoryVO _category;
private Vector _palModels;
private Vector _keywords;
private UserVO _author;
private Long _authorId;
private String _filePath;
private Long _roleId;
private RoleVO _role;
}
public class DownloadVO extends ValueObject implements SupportItemI, Serializable {
private Long _id;
private String _name;
private String _description;
private String _version;
private Date _creationDate;
private String _filePath;
private Long _categoryId;
private Long _roleId;
private Long _fileSize;
private Vector _palModels;
private Vector _keywords;
private CategoryVO _category;
private RoleVO _role;
}
public class KeywordVO extends ValueObject implements Serializable {
private Long _id;
private String _name;
}
public class PalModelVO extends ValueObject implements Serializable {
private Long _id;
private String _name;
private String _description;
}
public class RoleVO extends ValueObject implements Serializable {
private Long _id;
private String _name;
private String _description;
}
public class UserVO extends ValueObject implements Serializable {

private Long _id;
private String _firstName;
private String _lastName;
private String _userName;
private String _password;
private String _email;
private String _company;
private String _position;
private RoleVO _role;
private Long _roleId;
private boolean _authenticated;
}
And here is the repository_user.xml

?xml version=1.0 encoding=UTF-8?

!--   Definitions for ch.ctc.support.common.SupportItemI  --
class-descriptor class=ch.ctc.support.common.SupportItemI
extent-class class-ref=ch.ctc.support.document.DocumentVO /
extent-class class-ref=ch.ctc.support.download.DownloadVO /
/class-descriptor
!--  Definitions for extent ch.ctc.support.common.ValueObject  --
class-descriptor class=ch.ctc.support.common.ValueObject
extent-class class-ref=ch.ctc.support.category.CategoryVO /
extent-class class-ref=ch.ctc.support.document.DocumentVO /
extent-class class-ref=ch.ctc.support.user.UserVO /
extent-class class-ref=ch.ctc.support.user.RoleVO /
extent-class class-ref=ch.ctc.support.download.DownlaodVO /
extent-class class-ref=ch.ctc.support.keyword.KeywordVO /
extent-class class-ref=ch.ctc.support.palmodel.PalModelVO / 
/class-descriptor
!--  Definitions for ch.ctc.support.category.CategoryVO  --
class-descriptor
class=ch.ctc.support.category.CategoryVO
table=category

field-descriptor
id=1
name=_id
column=id
jdbc-type=BIGINT
primarykey=true
autoincrement=true
/
field-descriptor
id=2

Mapping Question

2004-01-01 Thread Patrick Scheuerer
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: Mapping Question

2004-01-01 Thread Patrick Scheuerer
ooops, I guess attachments are not allowed in this mailing list.

here's a link to the picture:
http://homepage.hispeed.ch/tabalooga/datamodel.jpg
the same problem of course also exists for the keyword table.

Thank you, Patrick

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


Vector not found in OJB Repository

2003-12-10 Thread Patrick Scheuerer
Hello OJB Group,

I wrote a test case to check if my OJB configuration works properly but
everytime I run it I get the following exception:

org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
java.util.Vector not found in OJB Repository

Here's the repository_user.xml

class-descriptor class=ch.ctc.support.member.MemberVO 
  table=member 
field-descriptor id=1 
  name=memberId 
  column=member_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/ 

field-descriptor id=2 
  name=firstName 
  column=first_name 
  jdbc-type=VARCHAR/ 

field-descriptor id=3 
  name=lastName 
  column=last_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=userName 
  column=user_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=password 
  column=password 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=6 
  name=email 
  column=email 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=7 
  name=companyId 
  column=company_id 
  jdbc-type=BIGINT/
  
reference-descriptor name=category 

class-ref=ch.ctc.suppport.CategoryVO 
  auto-retrieve=true
foreignkey field-id-ref=9/
/reference-descriptor
/class-descriptor

class-descriptor class=ch.ctc.support.document.DocumentVO 
  table=document 
field-descriptor id=1 
  name=documentId 
  column=document_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/


field-descriptor id=2 
  name=documentName 
  column=document_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=3 
  name=documentDescription 
  column=document_description 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=documentVersion 
  column=document_version 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=documentAbstract 
  column=document_abstract 
  jdbc-type=LONGVARBINARY/
   
field-descriptor id=6 
  name=creationDate 
  column=creation_date 
  jdbc-type=DATE/
  
field-descriptor id=7 
  name=palModel 
  column=pal_model_id 
  jdbc-type=BIGINT/
  
field-descriptor id=8 
  name=keywords 
  column=keyword_id 
  jdbc-type=BIGINT/
  
field-descriptor id=9 
  name=category 
 

Newbie needs help

2003-12-10 Thread Patrick Scheuerer
Hello everybody,

I just got started with OJB and i'm experiencing some problems. Here's the
scenario that i'm trying to get to work:

A DOCUMENT belongs to 1..n CATEGORY.
A DOCUMENT is relevant to 0..n PRODUCT_MODELs.
A DOCUMENT is written by 1..1 AUTHOR.
D DOCUMENT is described by 1..n KEYWORDs.

My first question is: since there are many-to-many relatioships between
DOCUMENT and CATEGORY and DOCUMENT and KEYWORDS there are two join tables
called DOCUMENT_CATEGORY and DOCUMENTS_KEYWORD. How does one handle join
tables needed by many-to-many in OJB?

All the data retrieved from the database (MySQL) should be wrapped in
ValueObject Classes.

Following is the repository_user.xml file that I'm using so far. Every time
I'm trying to save object to the datastore or try to retrieve them I get a
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException with the
following message: java.util.ArrayList not found in OJB Repository.

Somebody suggested yesterday to use a List instead of a Vector (I tried
Vectors first) but the result is the same.

I tips, hints, suggestions would be highly appreciated. TIA.

Patrick

-- start of repository_user.xml --
class-descriptor class=ch.ctc.support.member.MemberVO 
table=member 

field-descriptor id=1 
  name=memberId 
  column=member_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/ 

field-descriptor id=2 
  name=firstName 
  column=first_name 
  jdbc-type=VARCHAR/ 

field-descriptor id=3 
  name=lastName 
  column=last_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=userName 
  column=user_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=password 
  column=password 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=6 
  name=email 
  column=email 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=7 
  name=companyId 
  column=company_id 
  jdbc-type=BIGINT/
  
reference-descriptor name=category 

class-ref=ch.ctc.suppport.CategoryVO 
  auto-retrieve=true
foreignkey field-id-ref=9/
/reference-descriptor
/class-descriptor

class-descriptor class=ch.ctc.support.document.DocumentVO 
table=document 

field-descriptor id=1 
  name=documentId 
  column=document_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/


field-descriptor id=2 
  name=documentName 
  column=document_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=3 
  name=documentDescription 
  column=document_description 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=documentVersion 
  column=document_version 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=documentAbstract 
  column=document_abstract 
  jdbc-type=LONGVARBINARY/
   
field-descriptor 

RE: Newbie needs help

2003-12-10 Thread Patrick Scheuerer
 -Original Message-

 your repository_xml says: indirection-table=document_keyword.
 typo? (missing 's');

This is not a typo. The table is called document_keyword.

  handle join tables needed by many-to-many in OJB?
 
 see  .../db-ojb/src/test/org/apache/ojb/repository_junit.xml
 usage of 'indirection-table', e.g. Person - Role

I checked usage of 'indirection-table' with the Person - Role mapping and
it seems to be exactly like I used it. I can't find any difference


 I suggest that you compare your classes with the ones in 
 OJB's junit tests.

Couldn't find any differences. In junit tests Collections are used. I also
use Collections. 

 If you do not find the error, please post also your pc 
 classes source code.

In the following I included the source for all my value objects. I removed
getter/setter methods. I didn't include the repository.xml again.


--
package ch.ctc.support.document;

import java.sql.Date;
import java.util.Collection;
import java.util.Vector;

import ch.ctc.support.common.ValueObject;
import ch.ctc.support.member.MemberVO;

public class DocumentVO extends ValueObject {

private Long documentId;
private String documentName;
private String documentDescription;
private String documentVersion;
private byte[] documentAbstract;
private Date creationDate;
private Collection palModels;
private Collection keywords;
private Collection category;
private MemberVO documentAuthor;

}

--

package ch.ctc.support.category;

import ch.ctc.support.common.ValueObject;

public class KeywordVO extends ValueObject {

private Long keywordId;
private String keywordName;
}

--

package ch.ctc.support.category;

import ch.ctc.support.common.ValueObject;

public class CategoryVO extends ValueObject {

private Long categoryId;
private String categoryName;
private String categoryDescription;

}

--

package ch.ctc.support.member;

import ch.ctc.support.common.ValueObject;

public class MemberVO extends ValueObject {

private Long memberId;
private String firstName;
private String lastName;
private String userName;
private String password;
private String email;
private String company;
private int accessLevel;
}

--

package ch.ctc.support.member;

import ch.ctc.support.common.ValueObject;

public class CompanyVO extends ValueObject {

private Long companyId;
private String companyName;
}

--
package ch.ctc.support.common;

import java.io.Serializable;

public abstract class ValueObject implements Serializable{

public ValueObject() {
}

}

--






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



RE: Vector not found in OJB Repository

2003-12-10 Thread Patrick Scheuerer
Fixed it. Changed nothing though. Still the same problem 

 -Original Message-
 From: Anish [mailto:[EMAIL PROTECTED] 
 Sent: Donnerstag, 11. Dezember 2003 09:45
 To: [EMAIL PROTECTED]
 Subject: Re: Vector not found in OJB Repository
 
 hi,
  the foreignkey field-id-ref=9/ is wrong. where is the 
 field with id 9.
 check it out.
 Anish..
 
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.537 / Virus Database: 332 - Release Date: 11/6/2003
 
 
 
 -
 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]



Newbie needs help

2003-12-10 Thread Patrick Scheuerer
Hello everybody,

I just got started with OJB and i'm experiencing some problems. Here's the
scenario that i'm trying to get to work:

A DOCUMENT belongs to 1..n CATEGORY.
A DOCUMENT is relevant to 0..n PRODUCT_MODELs.
A DOCUMENT is written by 1..1 AUTHOR.
D DOCUMENT is described by 1..n KEYWORDs.

My first question is: since there are many-to-many relatioships between
DOCUMENT and CATEGORY and DOCUMENT and KEYWORDS there are two join tables
called DOCUMENT_CATEGORY and DOCUMENTS_KEYWORD. How does one handle join
tables needed by many-to-many in OJB?

All the data retrieved from the database (MySQL) should be wrapped in
ValueObject Classes.

Following is the repository_user.xml file that I'm using so far. Every time
I'm trying to save object to the datastore or try to retrieve them I get a
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException with the
following message: java.util.ArrayList not found in OJB Repository.

Somebody suggested yesterday to use a List instead of a Vector (I tried
Vectors first) but the result is the same.

I tips, hints, suggestions would be highly appreciated. TIA.

Patrick

-- start of repository_user.xml --
class-descriptor class=ch.ctc.support.member.MemberVO 
table=member 

field-descriptor id=1 
  name=memberId 
  column=member_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/ 

field-descriptor id=2 
  name=firstName 
  column=first_name 
  jdbc-type=VARCHAR/ 

field-descriptor id=3 
  name=lastName 
  column=last_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=userName 
  column=user_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=password 
  column=password 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=6 
  name=email 
  column=email 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=7 
  name=companyId 
  column=company_id 
  jdbc-type=BIGINT/
  
reference-descriptor name=category 

class-ref=ch.ctc.suppport.CategoryVO 
  auto-retrieve=true
foreignkey field-id-ref=9/
/reference-descriptor
/class-descriptor

class-descriptor class=ch.ctc.support.document.DocumentVO 
table=document 

field-descriptor id=1 
  name=documentId 
  column=document_id 
  jdbc-type=BIGINT 
  primarykey=true 
  autoincrement=true
  access=anonymous/


field-descriptor id=2 
  name=documentName 
  column=document_name 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=3 
  name=documentDescription 
  column=document_description 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=4 
  name=documentVersion 
  column=document_version 
  jdbc-type=VARCHAR/ 
  
field-descriptor id=5 
  name=documentAbstract 
  column=document_abstract 
  jdbc-type=LONGVARBINARY/
   
field-descriptor