DBCP, Oracle9i Blob/Clob broken

2005-03-03 Thread Danilo Tommasina
Hi,
I just saw another post about Oracle 9i and Blobs, so if somebody is going to 
get a look into it, here is some more:
When using the Oracle9i platform storing Blobs/Clobs does not work when using 
the DBCP connection factory 
(org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl)
This is because of the code in PlatformOracle9iImpl:
methodSetBlob = ClassHelper.getMethod( ps, setBLOB, new Class [] { 
Integer.TYPE, blobClass } );
The problem is that when using the DBCP connection factory the variable 'ps' 
does not contain an instance of proprietary OraclePreparedStatement with the 
proprietary setBLOB method.
It is first necessary to extract the OraclePreparedStatemnt from the 'DBCP 
PreparedStatemnt stack' until we reach the original statement.
Furthermore the Connection object bound to the OraclePreparedStatement must be 
used and not the one bound to the DBCP PreparedStatement.
And one more side notice: why the Oracle and Sybase (and maybe other) platforms are not configured to use SQL92 syntax? At least in Sybase there are less limitations on outer joins 
when using this syntax and it should be granted that you get same results on all platform when using the SQL92.

Below the code of the Platform implementation that we are using for Oracle 9i, configured for SQL92 syntax and with the workaround for the DBCP connection factory.
The code is ugly and may break if the DBCP API is modified, however I do not really see any better solution. (Maybe a recursive loop until the getDelegate() method can be found per 
reflection?)

Note that if p6spy is beeing used, the code will also not work, because the 
setBLOB method is also not available in the p6spy PreparedStatement wrapper.
And sorry for a couple of weeks more I'll be unable to post any test-cases.

public class PlatformANSIOracle9iImpl extends PlatformOracle9iImpl {
/** Creates a new instance of PlatformOracle9iImpl */
public PlatformANSIOracle9iImpl() {
super();
}
/** Get join syntax type for this RDBMS - one on of the constants from
 * JoinSyntaxType interface
 * @return SQL92_NOPAREN_JOIN_SYNTAX
 */
public byte getJoinSyntaxType() {
return SQL92_NOPAREN_JOIN_SYNTAX;
}
/** @see Platform#setObjectForStatement */
public void setObjectForStatement( PreparedStatement ps, int index, Object 
value, int sqlType ) throws SQLException {
boolean blobHandlingSupported = false;
boolean clobHandlingSupported = false;
Method methodSetBlob = null;
Method methodSetClob = null;
PreparedStatement innerPS;
if ( ps instanceof DelegatingPreparedStatement ) {
innerPS = (PreparedStatement) ((DelegatingPreparedStatement) 
ps).getDelegate();
if ( innerPS instanceof PoolablePreparedStatement ) {
innerPS = (PreparedStatement) ((PoolablePreparedStatement) 
innerPS).getDelegate();
}
} else {
innerPS = ps;
}
// Check for Oracle JDBC-driver LOB-support
if ( sqlType == Types.CLOB ) {
try {
Class clobClass = ClassHelper.getClass( oracle.sql.CLOB, 
false );
methodSetClob = ClassHelper.getMethod( innerPS, setCLOB, new 
Class [] { Integer.TYPE, clobClass } );
clobHandlingSupported = methodSetClob != null;
} catch ( Exception ignore ) {
// ignore it
}
} else if (sqlType == Types.BLOB ) {
try {
Class blobClass = ClassHelper.getClass( oracle.sql.BLOB, 
false );
methodSetBlob = ClassHelper.getMethod( innerPS, setBLOB, new 
Class [] { Integer.TYPE, blobClass } );
blobHandlingSupported = methodSetBlob != null;
} catch ( Exception ignore ) {
// ignore it
}
}
if ( clobHandlingSupported  ( value instanceof String ) ) {
try {
Object clob = Oracle9iLobHandler.createCLOBFromString( 
innerPS.getConnection(), (String) value);
methodSetClob.invoke( innerPS, new Object[] { new 
Integer(index), clob } );
} catch (Exception e) {
throw new SQLException( e.getLocalizedMessage() );
}
} else if ( blobHandlingSupported  ( value instanceof byte[] ) ) {
try {
Object blob = Oracle9iLobHandler.createBLOBFromByteArray( 
innerPS.getConnection(), (byte[]) value );
methodSetBlob.invoke( innerPS, new Object[] {new Integer( index 
), blob } );
} catch ( Exception e ) {
throw new SQLException( e.getLocalizedMessage() );
}
} else {
// Fall-through to superclass
super.setObjectForStatement( ps, index, value, sqlType );
}
}
}
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL 

ojb and interface driven design

2005-03-03 Thread Maksimenko Alexander
hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);
Standard approach in mapping is not working ;(
class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=groupId
		column=GROUP_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.Group
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=managerId
		column=MANAGER_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=manager
		class-ref=test.ojb.datamodel.User
		proxy=true
	
		foreignkey field-ref=managerId/
	/reference-descriptor	
/class-descriptor


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


RE: ojb and interface driven design

2005-03-03 Thread David . WIESZTAL
You should map your DB and make the queries with the xxxImpl classes.
In your case :
QueryByCriteria query = QueryFactory.newQuery(UserImpl.class,new
Criteria());
and 
   class-descriptor 
class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
   /class-descriptor
is useless.

David WIESZTAL.


-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 5:25 PM
To: OJB Users List
Subject: ojb and interface driven design


hi!

it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(

class-descriptor 
class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
class=test.ojb.datamodel.impl.UserImpl 
table=USER 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor 
name=id 
column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/ 
field-descriptor 
name=groupId
column=GROUP_ID
jdbc-type=INTEGER
access=anonymous
/  
reference-descriptor
name=group
class-ref=test.ojb.datamodel.Group
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor 
/class-descriptor

class-descriptor 
class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor 
name=id 
column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/ 
field-descriptor 
name=managerId
column=MANAGER_ID
jdbc-type=INTEGER
access=anonymous
/  
reference-descriptor
name=manager
class-ref=test.ojb.datamodel.User
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor 
/class-descriptor




-
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 and interface driven design

2005-03-03 Thread Maksimenko Alexander
Thanks for answer but it doesnt solve the problem:
ojb generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID = 
a1.id and a1.manager_id=?

[EMAIL PROTECTED] wrote:
You should map your DB and make the queries with the xxxImpl classes.
In your case :
QueryByCriteria query = QueryFactory.newQuery(UserImpl.class,new
Criteria());
and 
  class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
  /class-descriptor
is useless.

David WIESZTAL.
-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 5:25 PM
To: OJB Users List
Subject: ojb and interface driven design

hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);
Standard approach in mapping is not working ;(
class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=groupId
		column=GROUP_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.Group
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=managerId
		column=MANAGER_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=manager
		class-ref=test.ojb.datamodel.User
		proxy=true
	
		foreignkey field-ref=managerId/
	/reference-descriptor	
/class-descriptor


-
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: ojb and interface driven design

2005-03-03 Thread Armin Waibel
Hi,
your mapping and query seems ok. Could you post the stack trace? Did you 
try latest from CVS OJB 1.0.x branch (branch OJB_1_0_RELEASE)?
In OJB test-suite we have a similar test 
ReferenceTest#testDeepPathQuery(), this test pass.

regards,
Armin
Maksimenko Alexander wrote:
hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);
Standard approach in mapping is not working ;(
class-descriptor class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.UserImpl 
table=USER factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   
field-descriptor name=groupId
column=GROUP_ID
jdbc-type=INTEGER
access=anonymous
/   
reference-descriptor
name=group
class-ref=test.ojb.datamodel.Group
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor   
/class-descriptor

class-descriptor class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   
field-descriptor name=managerId
column=MANAGER_ID
jdbc-type=INTEGER
access=anonymous
/   
reference-descriptor
name=manager
class-ref=test.ojb.datamodel.User
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor   
/class-descriptor


-
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 and interface driven design

2005-03-03 Thread Maksimenko Alexander
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID = 
a1.id and a1.manager_id=?

Armin Waibel wrote:
Hi,
your mapping and query seems ok. Could you post the stack trace? Did 
you try latest from CVS OJB 1.0.x branch (branch OJB_1_0_RELEASE)?
In OJB test-suite we have a similar test 
ReferenceTest#testDeepPathQuery(), this test pass.

regards,
Armin
Maksimenko Alexander wrote:
hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group 
group; access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new 
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(
class-descriptor class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.UserImpl 
table=USER factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   field-descriptor 
name=groupId
column=GROUP_ID
jdbc-type=INTEGER
access=anonymous
/   reference-descriptor
name=group
class-ref=test.ojb.datamodel.Group
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor   /class-descriptor

class-descriptor class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   field-descriptor 
name=managerId
column=MANAGER_ID
jdbc-type=INTEGER
access=anonymous
/   reference-descriptor
name=manager
class-ref=test.ojb.datamodel.User
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor   /class-descriptor


-
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: ojb and interface driven design

2005-03-03 Thread Armin Waibel
Maksimenko Alexander wrote:
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID = 
a1.id and a1.manager_id=?

AFAIK Jakob fixed some bugs in conjunction with query references. So I 
recommend to give upcoming OJB 1.0.2 from OJB_1_0_RELEASE branch a change.

regards,
Armin

Armin Waibel wrote:
Hi,
your mapping and query seems ok. Could you post the stack trace? Did 
you try latest from CVS OJB 1.0.x branch (branch OJB_1_0_RELEASE)?
In OJB test-suite we have a similar test 
ReferenceTest#testDeepPathQuery(), this test pass.

regards,
Armin
Maksimenko Alexander wrote:
hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group 
group; access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new 
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(
class-descriptor class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.UserImpl 
table=USER factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   field-descriptor 
name=groupId
column=GROUP_ID
jdbc-type=INTEGER
access=anonymous
/   reference-descriptor
name=group
class-ref=test.ojb.datamodel.Group
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor   /class-descriptor

class-descriptor class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor name=id column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/   field-descriptor 
name=managerId
column=MANAGER_ID
jdbc-type=INTEGER
access=anonymous
/   reference-descriptor
name=manager
class-ref=test.ojb.datamodel.User
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor   /class-descriptor


-
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: ojb and interface driven design

2005-03-03 Thread Gelhar, Wallace Joseph
I've ran into this before.  I think the solution I found was to map the
reference / collection descriptor classes to the implementing descriptor
as follows:

class-descriptor 
class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptorclass-descriptor
class=test.ojb.datamodel.impl.UserImpl 
table=USER 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor 
...
reference-descriptor
name=group
class-ref=test.ojb.datamodel.GroupImpl
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor 
/class-descriptor

class-descriptor 
class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor 
...
reference-descriptor
name=manager
class-ref=test.ojb.datamodel.UserImpl
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor 
/class-descriptor

Also just note that it usually doesn't pay to proxy reference
descriptors since these can often be retrieved effeciently with one
query to the database.  Although it might make sense if you have a lot
of 1-1 relations that are not routinely used.  I usually proxy
collection descriptors though.

The query for the interface class is perfectly fine.

BTW is user really a 1-1 with group?  I would normally make this a 1-m
relation.

Hope this helps.

Wally

-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 10:25 AM
To: OJB Users List
Subject: ojb and interface driven design

hi!

it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(

class-descriptor 
class=test.ojb.datamodel.User
extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
class=test.ojb.datamodel.impl.UserImpl 
table=USER 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createUser
field-descriptor 
name=id 
column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/ 
field-descriptor 
name=groupId
column=GROUP_ID
jdbc-type=INTEGER
access=anonymous
/  
reference-descriptor
name=group
class-ref=test.ojb.datamodel.Group
proxy=true

foreignkey field-ref=groupId/
/reference-descriptor 
/class-descriptor

class-descriptor 
class=test.ojb.datamodel.Group
extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
class=test.ojb.datamodel.impl.GroupImpl 
table=GROUP1 
factory-class=test.ojb.datamodel.impl.FactoryImpl
factory-method=createGroup
field-descriptor 
name=id 
column=ID 
jdbc-type=INTEGER
primarykey=true
nullable=false
autoincrement=true
access=readonly/ 
field-descriptor 
name=managerId
column=MANAGER_ID
jdbc-type=INTEGER
access=anonymous
/  
reference-descriptor
name=manager
class-ref=test.ojb.datamodel.User
proxy=true

foreignkey field-ref=managerId/
/reference-descriptor 
/class-descriptor




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


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

Re: ojb and interface driven design

2005-03-03 Thread Thomas Dudziak
I was wondering why you map the Impl classes at all ? You can declare
the fields for the interface, you only need to change the
PersistentFieldClass in OJB.properties to
PersistentFieldIntrospectorImpl or PersistentFieldAutoProxyImpl.
I use it this way all the time (with factory-class/factory-method) and it works.

Tom

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



Re: ojb and interface driven design

2005-03-03 Thread Maksimenko Alexander
Armin Waibel wrote:
Maksimenko Alexander wrote:
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID = 
a1.id and a1.manager_id=?

AFAIK Jakob fixed some bugs in conjunction with query references. So I 
recommend to give upcoming OJB 1.0.2 from OJB_1_0_RELEASE branch a 
change.

great!
i look forward to this release
i hope it'll solve my problem ;)

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


Re: ojb and interface driven design

2005-03-03 Thread Armin Waibel
I saw ReferenceTest test worked with OJB 1.0.1 too, with a different 
mapping of the interface. Did you tried to declare the 
reference-descriptor and fk-field in the interface class mapping too?

e.g.
Class RefObject is an interface
class-descriptor class=org.apache.ojb.broker.ReferenceTest$RefObject
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjA/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjB/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjC/

field-descriptor
 name=fkId
 column=FK_REF
 primarykey=false
 jdbc-type=INTEGER
access=anonymous
/
reference-descriptor
name=ref
class-ref=org.apache.ojb.broker.ReferenceTest$RefObject
proxy=false
auto-retrieve=true
auto-update=true
auto-delete=false
foreignkey field-ref=fkId/
/reference-descriptor
/class-descriptor
If this doesn't work, try the mapping mentioned by Tom.
regards,
Armin
Maksimenko Alexander wrote:
Armin Waibel wrote:
Maksimenko Alexander wrote:
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID = 
a1.id and a1.manager_id=?

AFAIK Jakob fixed some bugs in conjunction with query references. So I 
recommend to give upcoming OJB 1.0.2 from OJB_1_0_RELEASE branch a 
change.

great!
i look forward to this release
i hope it'll solve my problem ;)

-
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 and interface driven design

2005-03-03 Thread Maksimenko Alexander
thanks for idea but its unfortunately doesn't fit to me :(
because i'm need using proxies for perfomance reasons
of cause user a 1-m to group - but i created this example to simplify 
understanding by problem - in real project my classes are big enough and 
ojb descriptor is huge ;)

Gelhar, Wallace Joseph wrote:
I've ran into this before.  I think the solution I found was to map the
reference / collection descriptor classes to the implementing descriptor
as follows:
class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptorclass-descriptor
class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor 
...
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.GroupImpl
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor 
...
	reference-descriptor
		name=manager
		class-ref=test.ojb.datamodel.UserImpl
		proxy=true
	
		foreignkey field-ref=managerId/
	/reference-descriptor	
/class-descriptor

Also just note that it usually doesn't pay to proxy reference
descriptors since these can often be retrieved effeciently with one
query to the database.  Although it might make sense if you have a lot
of 1-1 relations that are not routinely used.  I usually proxy
collection descriptors though.
The query for the interface class is perfectly fine.
BTW is user really a 1-1 with group?  I would normally make this a 1-m
relation.
Hope this helps.
Wally
-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 10:25 AM
To: OJB Users List
Subject: ojb and interface driven design

hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;(
lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()},
class UserImpl implements User{private Integer id; private Group group; 
access methods}

interface Group{Integer getId(),User getManager()},
class GroupImpl implements Group{private Integer id;privarte User 
manager; access methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4));
Collection users = broker.getCollectionByQuery(query);
Standard approach in mapping is not working ;(
class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=groupId
		column=GROUP_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.Group
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=managerId
		column=MANAGER_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=manager
		class-ref=test.ojb.datamodel.User
		proxy=true
	
		foreignkey field-ref=managerId/
	/reference-descriptor	
/class-descriptor


-
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: ojb and interface driven design

2005-03-03 Thread Maksimenko Alexander
but in this case i need create setters in interface, isn't it ?
Thomas Dudziak wrote:
I was wondering why you map the Impl classes at all ? You can declare
the fields for the interface, you only need to change the
PersistentFieldClass in OJB.properties to
PersistentFieldIntrospectorImpl or PersistentFieldAutoProxyImpl.
I use it this way all the time (with factory-class/factory-method) and it works.
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]


RE: ojb and interface driven design

2005-03-03 Thread Gelhar, Wallace Joseph
The proxies comment is irrelevant to the solution I noted.

You need to change:

reference-descriptor name=group
class-ref=test.ojb.datamodel.Group proxy=true 

To:

reference-descriptor name=group
class-ref=test.ojb.datamodel.GroupImpl proxy=true 



As far as my comment regarding proxies, in general we get better
performance by NOT proxying reference descriptors.  We do however
increase performance by proxying collection descriptors.  I would
suggest running tests both ways in your environment.

Wally

-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 11:19 AM
To: OJB Users List
Subject: Re: ojb and interface driven design

thanks for idea but its unfortunately doesn't fit to me :( because i'm
need using proxies for perfomance reasons

of cause user a 1-m to group - but i created this example to simplify
understanding by problem - in real project my classes are big enough and
ojb descriptor is huge ;)


Gelhar, Wallace Joseph wrote:

I've ran into this before.  I think the solution I found was to map the

reference / collection descriptor classes to the implementing 
descriptor as follows:

class-descriptor 
   class=test.ojb.datamodel.User
   extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptorclass-descriptor
class=test.ojb.datamodel.impl.UserImpl 
   table=USER 
   factory-class=test.ojb.datamodel.impl.FactoryImpl
   factory-method=createUser
   field-descriptor
...
   reference-descriptor
   name=group
   class-ref=test.ojb.datamodel.GroupImpl
   proxy=true
   
   foreignkey field-ref=groupId/
   /reference-descriptor 
/class-descriptor

class-descriptor 
   class=test.ojb.datamodel.Group
   extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
   class=test.ojb.datamodel.impl.GroupImpl 
   table=GROUP1 
   factory-class=test.ojb.datamodel.impl.FactoryImpl
   factory-method=createGroup
   field-descriptor
...
   reference-descriptor
   name=manager
   class-ref=test.ojb.datamodel.UserImpl
   proxy=true
   
   foreignkey field-ref=managerId/
   /reference-descriptor 
/class-descriptor

Also just note that it usually doesn't pay to proxy reference 
descriptors since these can often be retrieved effeciently with one 
query to the database.  Although it might make sense if you have a lot 
of 1-1 relations that are not routinely used.  I usually proxy 
collection descriptors though.

The query for the interface class is perfectly fine.

BTW is user really a 1-1 with group?  I would normally make this a 1-m 
relation.

Hope this helps.

Wally

-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 03, 2005 10:25 AM
To: OJB Users List
Subject: ojb and interface driven design

hi!

it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;( lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()}, class UserImpl 
implements User{private Integer id; private Group group; access 
methods}

interface Group{Integer getId(),User getManager()}, class GroupImpl 
implements Group{private Integer id;privarte User manager; access 
methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4)); 
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(

class-descriptor 
   class=test.ojb.datamodel.User
   extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
   class=test.ojb.datamodel.impl.UserImpl 
   table=USER 
   factory-class=test.ojb.datamodel.impl.FactoryImpl
   factory-method=createUser
   field-descriptor 
   name=id 
   column=ID 
   jdbc-type=INTEGER
   primarykey=true
   nullable=false
   autoincrement=true
   access=readonly/ 
   field-descriptor 
   name=groupId
   column=GROUP_ID
   jdbc-type=INTEGER
   access=anonymous
   /  
   reference-descriptor
   name=group
   class-ref=test.ojb.datamodel.Group
   proxy=true
   
   foreignkey field-ref=groupId/
   /reference-descriptor 
/class-descriptor

class-descriptor 
   class=test.ojb.datamodel.Group
   extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
   class=test.ojb.datamodel.impl.GroupImpl 
   table=GROUP1 
   factory-class=test.ojb.datamodel.impl.FactoryImpl
   

Mapping question

2005-03-03 Thread Georg Müller
Hi,
I have an object User who has 2 addresses, home and work.
User is mapped to a table user (no problem here).
Both home and work address are mapped to a table address.
This table has a composite primary key: login and type
 - login from table user as a foreign key
 - type is a string (or enum) home and work
I have tried the following without success:
in User description:
reference-descriptor
  name=homeAddress
  class-ref=Address
  auto-update=true
  auto-delete=true
  attribute attribute-name=type attribute-value=heimat/
  foreignkey field-ref=login /
/reference-descriptor
and in Address description:
field-descriptor
  name=login
  column=login
  primarykey=true /
field-descriptor
  name=type
  column=type
  primarykey=true /
Is it possible to make it run anyhow?
Regards,
Georg
P.S.: Please CC me
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: ojb and interface driven design

2005-03-03 Thread Maksimenko Alexander
but...
according to dtd i should write either extent or field-descripto 
elements  -

!ELEMENT class-descriptor
   ((documentation?, extent-class+, attribute*) |
   (documentation?, object-cache?, extent-class*, field-descriptor+,
reference-descriptor*, collection-descriptor*,
index-descriptor*, attribute*,
insert-procedure?, update-procedure?, delete-procedure?))
its dtd from 1.0.1
Armin Waibel wrote:
I saw ReferenceTest test worked with OJB 1.0.1 too, with a different 
mapping of the interface. Did you tried to declare the 
reference-descriptor and fk-field in the interface class mapping too?

e.g.
Class RefObject is an interface
class-descriptor class=org.apache.ojb.broker.ReferenceTest$RefObject
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjA/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjB/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjC/

field-descriptor
 name=fkId
 column=FK_REF
 primarykey=false
 jdbc-type=INTEGER
access=anonymous
/
reference-descriptor
name=ref
class-ref=org.apache.ojb.broker.ReferenceTest$RefObject
proxy=false
auto-retrieve=true
auto-update=true
auto-delete=false
foreignkey field-ref=fkId/
/reference-descriptor
/class-descriptor
If this doesn't work, try the mapping mentioned by Tom.
regards,
Armin
Maksimenko Alexander wrote:
Armin Waibel wrote:
Maksimenko Alexander wrote:
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID 
= a1.id and a1.manager_id=?

AFAIK Jakob fixed some bugs in conjunction with query references. So 
I recommend to give upcoming OJB 1.0.2 from OJB_1_0_RELEASE branch a 
change.

great!
i look forward to this release
i hope it'll solve my problem ;)

-
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: ojb and interface driven design

2005-03-03 Thread Armin Waibel
Maksimenko Alexander wrote:
but...
according to dtd i should write either extent or field-descripto 
elements  -

in the second part a extent-class* declaration is defined too. The 
first part mean that at least an extent-class definition is needed.

Armin
!ELEMENT class-descriptor
   ((documentation?, extent-class+, attribute*) |
   (documentation?, object-cache?, extent-class*, field-descriptor+,
reference-descriptor*, collection-descriptor*,
index-descriptor*, attribute*,
insert-procedure?, update-procedure?, delete-procedure?))
its dtd from 1.0.1
Armin Waibel wrote:
I saw ReferenceTest test worked with OJB 1.0.1 too, with a different 
mapping of the interface. Did you tried to declare the 
reference-descriptor and fk-field in the interface class mapping too?

e.g.
Class RefObject is an interface
class-descriptor class=org.apache.ojb.broker.ReferenceTest$RefObject
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjA/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjB/
extent-class 
class-ref=org.apache.ojb.broker.ReferenceTest$ObjC/

field-descriptor
 name=fkId
 column=FK_REF
 primarykey=false
 jdbc-type=INTEGER
access=anonymous
/
reference-descriptor
name=ref
class-ref=org.apache.ojb.broker.ReferenceTest$RefObject
proxy=false
auto-retrieve=true
auto-update=true
auto-delete=false
foreignkey field-ref=fkId/
/reference-descriptor
/class-descriptor
If this doesn't work, try the mapping mentioned by Tom.
regards,
Armin
Maksimenko Alexander wrote:
Armin Waibel wrote:
Maksimenko Alexander wrote:
I'm using 1.0.1 version
ojb doesnt produce exception but it generates
SELECT A0.GROUP_ID,A0.ID FROM USER A0 WHERE A0.GROUP_ID = ?
instead of:
SELECT A0.GROUP_ID,A0.ID FROM USER A0, group1 a1 WHERE A0.GROUP_ID 
= a1.id and a1.manager_id=?

AFAIK Jakob fixed some bugs in conjunction with query references. So 
I recommend to give upcoming OJB 1.0.2 from OJB_1_0_RELEASE branch a 
change.

great!
i look forward to this release
i hope it'll solve my problem ;)

-
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: ojb and interface driven design

2005-03-03 Thread Maksimenko Alexander
yes you are right - its solution
but unfortunatelly it's not convenient to me ;(
i have 71 beans now and i'm using xdoclet - so when I' ll decide replace 
GroupImpl to GroupAnotherImpl i'll have much work
but its better then nothing  - thanks ;)
if I want find another solution I'll use yours

about proxies - my objects are high coupled - so I'll risk to fetch  
huge amount not needed objects  in some cases - so memory  becomes a 
problem too

Gelhar, Wallace Joseph wrote:
The proxies comment is irrelevant to the solution I noted.
You need to change:
reference-descriptor name=group
class-ref=test.ojb.datamodel.Group proxy=true 
To:
reference-descriptor name=group
class-ref=test.ojb.datamodel.GroupImpl proxy=true 

As far as my comment regarding proxies, in general we get better
performance by NOT proxying reference descriptors.  We do however
increase performance by proxying collection descriptors.  I would
suggest running tests both ways in your environment.
Wally
-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 11:19 AM
To: OJB Users List
Subject: Re: ojb and interface driven design

thanks for idea but its unfortunately doesn't fit to me :( because i'm
need using proxies for perfomance reasons
of cause user a 1-m to group - but i created this example to simplify
understanding by problem - in real project my classes are big enough and
ojb descriptor is huge ;)
Gelhar, Wallace Joseph wrote:
 

I've ran into this before.  I think the solution I found was to map the
   

 

reference / collection descriptor classes to the implementing 
descriptor as follows:

class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptorclass-descriptor
class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor
...
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.GroupImpl
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor
...
	reference-descriptor
		name=manager
		class-ref=test.ojb.datamodel.UserImpl
		proxy=true
	
		foreignkey field-ref=managerId/
	/reference-descriptor	
/class-descriptor

Also just note that it usually doesn't pay to proxy reference 
descriptors since these can often be retrieved effeciently with one 
query to the database.  Although it might make sense if you have a lot 
of 1-1 relations that are not routinely used.  I usually proxy 
collection descriptors though.

The query for the interface class is perfectly fine.
BTW is user really a 1-1 with group?  I would normally make this a 1-m 
relation.

Hope this helps.
Wally
-Original Message-
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 03, 2005 10:25 AM
To: OJB Users List
Subject: ojb and interface driven design
hi!
it's wondering but I found out that  its difficult to use interface 
driven design with ojb ;( lets consider a simple 2-table example:

interface User{Integer getId(),Group getGroup()}, class UserImpl 
implements User{private Integer id; private Group group; access 
methods}

interface Group{Integer getId(),User getManager()}, class GroupImpl 
implements Group{private Integer id;privarte User manager; access 
methods}

What repository descriptor should be to get correct results with the 
following query:

QueryByCriteria query = QueryFactory.newQuery(User.class,new
Criteria());
query.getCriteria().addEqualTo(group.manager.id,new Integer(4)); 
Collection users = broker.getCollectionByQuery(query);

Standard approach in mapping is not working ;(
class-descriptor 
	class=test.ojb.datamodel.User
	extent-class class-ref=test.ojb.datamodel.impl.UserImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.UserImpl 
	table=USER 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createUser
	field-descriptor 
		name=id 
		column=ID 
		jdbc-type=INTEGER
		primarykey=true
		nullable=false
		autoincrement=true
		access=readonly/	
	field-descriptor 
		name=groupId
		column=GROUP_ID
		jdbc-type=INTEGER
		access=anonymous
	/	
	reference-descriptor
		name=group
		class-ref=test.ojb.datamodel.Group
		proxy=true
	
		foreignkey field-ref=groupId/
	/reference-descriptor	
/class-descriptor

class-descriptor 
	class=test.ojb.datamodel.Group
	extent-class class-ref=test.ojb.datamodel.impl.GroupImpl/
/class-descriptor
class-descriptor 
	class=test.ojb.datamodel.impl.GroupImpl 
	table=GROUP1 
	factory-class=test.ojb.datamodel.impl.FactoryImpl
	factory-method=createGroup
	field-descriptor 
		name=id 
		column=ID 
		

Re: Mapping question

2005-03-03 Thread Georg Müller
Sorry for that second posting. I sent this before I subscribed to the 
list, so I thought it will not be posted (now, with a latency of nearly 
one day)

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


RE: Mapping question

2005-03-03 Thread Günther Wieser
hi,

as far as i understand this, you try to differentiate by the value of
adress.type whether an adress is a home wor work adress?
well, i have no solution for that, but i tried it here with a similair data
structur, and it didn't work either.
to be honest i'm not sure if this is the intended use for attribute in
collection-descriptor or reference-descriptor, because i didn't find
anything in the docs. all i found was an example in the ojb test cases in
repository_junit.xml, but the corresponding source code didn't tell me
anything i could understand.

so, long speach, short meaning: i'm also interested in a solution for that!

kr,
guenther


-Original Message-
From: Georg Müller [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 02, 2005 9:24 PM
To: ojb-user@db.apache.org
Subject: Mapping question

Hi,

I have an object User who has 2 addresses, home and work.

User is mapped to a table user (no problem here).

Both home and work address are mapped to a table address.
This table has a composite primary key: login and type
  - login from table user as a foreign key
  - type is a string (or enum) home and work

I have tried the following without success:

in User description:

reference-descriptor
   name=homeAddress
   class-ref=Address
   auto-update=true
   auto-delete=true
   attribute attribute-name=type attribute-value=heimat/
   foreignkey field-ref=login /
/reference-descriptor


and in Address description:

field-descriptor
   name=login
   column=login
   primarykey=true /

field-descriptor
   name=type
   column=type
   primarykey=true /


Is it possible to make it run anyhow?

Regards,
Georg

P.S.: Please CC me

-
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

2005-03-03 Thread Armin Waibel
Hi,
not sure that I understand the problem.
Each User has two Address attributes ('home' and 'work'), both are of 
the same type 'Address' (both 1:1 references), you don't use extension 
classes AddressHome and AddressWork objects. Address use a composite PK 
('login' and 'type').

In this case each reference has to use a composite FK key too.
in User (assume the 'login' datatype is INTEGER and User use an 
autoincrement PK, only show mapping for the 'home' reference, 'work' 
will be the same):

You need a FK field for each PK value of the referenced object, if you 
use 'anonymous' fields, you don't need a real fields in your 
persistent object class (User) - more info see docs.
http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+

field-descriptor
 name=fkLoginHome
 column=FK_LOGIN_HOME
 jdbc-type=INTEGER
access=anonymous
/
field-descriptor
 name=fkTypeHome
 column=FK_TYPE_HOME
 jdbc-type=VARCHAR
access=anonymous
/
reference-descriptor
   name=homeAddress
   class-ref=Address
   auto-retrieve=true
   auto-update=true
   auto-delete=true
   foreignkey field-ref=fkLoginHome /
   foreignkey field-ref=fkTypeHome /
/reference-descriptor
In Address you use the composite PK and both attributes has to be set by 
hand (no PK auto-generation was used) and the 'login' field is a FK from 
User table. This will make things complicated, because on insert OJB 
will first store the 1:1 references, but in your case we need the 
'login' PK first. So we need a workaround when insert User objects:

broker.beginTransaction();
User user = new User();
broker.store(user);
// now the PK ('login' field in User) is specified
Address home = new Address();
home.setLogin(user.getLogin());
home.setType(home);
user.setHome(home);
//
broker.store(user);
broker.commitTransaction();
Things will be easier when you use an single autoincremented PK field in 
Address. In this case all will be handled by OJB and you only need 
single FK field-descriptor in User:

broker.beginTransaction();
User user = new User();
Address home = new Address();
home.setType(home);
user.setHome(home);
broker.store(user);
broker.commitTransaction();
regards,
Armin
Günther Wieser wrote:
hi,
as far as i understand this, you try to differentiate by the value of
adress.type whether an adress is a home wor work adress?
well, i have no solution for that, but i tried it here with a similair data
structur, and it didn't work either.
to be honest i'm not sure if this is the intended use for attribute in
collection-descriptor or reference-descriptor, because i didn't find
anything in the docs. all i found was an example in the ojb test cases in
repository_junit.xml, but the corresponding source code didn't tell me
anything i could understand.
so, long speach, short meaning: i'm also interested in a solution for that!
kr,
guenther
-Original Message-
From: Georg Müller [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 02, 2005 9:24 PM
To: ojb-user@db.apache.org
Subject: Mapping question

Hi,
I have an object User who has 2 addresses, home and work.
User is mapped to a table user (no problem here).
Both home and work address are mapped to a table address.
This table has a composite primary key: login and type
  - login from table user as a foreign key
  - type is a string (or enum) home and work
I have tried the following without success:
in User description:
reference-descriptor
   name=homeAddress
   class-ref=Address
   auto-update=true
   auto-delete=true
   attribute attribute-name=type attribute-value=heimat/
   foreignkey field-ref=login /
/reference-descriptor
and in Address description:
field-descriptor
   name=login
   column=login
   primarykey=true /
field-descriptor
   name=type
   column=type
   primarykey=true /
Is it possible to make it run anyhow?
Regards,
Georg
P.S.: Please CC me
-
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: ojb and interface driven design

2005-03-03 Thread Thomas Dudziak
Yes, you need to declare getters and setters, at least for the fields
that are used for primarykeys and foreignkeys.
But the benefit is that you can put whatever implementation you see
fit, the do not even need to have actual java fields for the values.
And the speed hit because of the reflection is not that much because
the field descriptor caches the method object, so it is minor
especially when compared to the database hit.

Btw, this works really nice with the XDoclet module because you don't
have to put anything into the impl classes at all, only in the
interface at the getters and/or setters.

Tom

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



Pooling questions

2005-03-03 Thread Vincent Frison
Hi all,

I have sometimes troubles with pooling. One of the most frequent exception is:
An action has failed: Borrow broker from pool failed, using PBKey 
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null, password=null

It seems that I explode the broker pool capacity (altough I close brokers as 
soon as possible). I'm not very familiar with pooling so please don't blame 
me. My poor brain can just understand that there is two different pools: one 
for the OJB brokers and optionally another one for the JDBC connections. 
Okay. But there is a lot of points which are very dark.

1) Configuring the PB pool

The default values in OJB.properties looks very strange for me:
maxIdle=-1
timeBetweenEvictionRunsMillis=-1
If I read the comments, there's no limit and no eviction for idle brokers, so 
it it sounds for me that they can grow indefinitely (even if 
whenExhaustedAction != 2)! Or maybe the maxActive value limits idle brokers 
too?

2) Configuring the JDBC connections pool

a) Regarding to OJB:

Depending on how OJB brokers handles JDBC connections, is there any rules to 
respect when configuring this the pools, e.g. PB pool maxActive  JDBC pool 
maxActive? I guess this is not mandatory since OJB brokers use JDBC 
connection factory (which could not use pooling btw) and close connections 
properly, but i'd like to be sure..

b) jndi-datasource-name vs. connection-pool:

I use OJB within Tomcat 5.0.x and I have a JNDI DataSource defined in Tomcat 
(DBCP Factory). If I want to use it with OJB, I have to declare it in the 
jndi-datasource-name attribute of jdbc-connection-descriptor. In this 
case does it mean that OJB don't manage the pool itself and that the 
connection-pool declaration will be ignored? Is the 
ConnectionFactoryDBCPImpl mandatory in that case? Apparently it works better 
if I use it (compared to ConnectionFactoryPooledImpl). But if a JNDI 
DataSource - which is not implemented with DBCP - is declared in my 
container, should I stay with the default implementation?

Thanks a lot..

Vinz

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



Re: Mapping question

2005-03-03 Thread Thomas Dudziak
As far as I understand he wants to use a reference that refers to a
class with a compound primarykey, where one of the foreignkey values
is fixed:

reference-descriptor name=homeAddress
  class-ref=Address
  auto-update=true
  auto-delete=true
  foreignkey field-ref=login /
  foreignkey expression=heimat /
  !-- the second part of the fk relating to pk part 'type', is fixed
to heimat --
/reference-descriptor

That would actually be a neat feature to have IMO ?!

Tom

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



Re: Mapping question

2005-03-03 Thread Georg Müller
Thomas Dudziak wrote:
As far as I understand he wants to use a reference that refers to a
class with a compound primarykey, where one of the foreignkey values
is fixed:
reference-descriptor name=homeAddress
  class-ref=Address
  auto-update=true
  auto-delete=true
  foreignkey field-ref=login /
  foreignkey expression=heimat /
  !-- the second part of the fk relating to pk part 'type', is fixed
to heimat --
/reference-descriptor
Yes, that is what I am searching for.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Oracle 9i date-timestamp tip

2005-03-03 Thread Bruno CROS
Even if it has been already post, i just want to clarify the tip :

- according to Oracle 9i notes 

http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#08_01

it's important to note that mapping date attributes such as
java.sql.Time java.util.Date (with hours ...) and even
java.sql.Timestamp using DATE oracle type  IS NOT POSSIBLE since
Oracle 9.2 !! (Hours are lost ... with all it can occurs too !)

The first tip of Oracle is the best one. Replacing all DATE columns by
TIMESTAMP columns work very well, so you are not obliged to use
V8compatibility tip (what did not work for me (sorry!)) and can use
new 9i types.

For me, the problem was to keep on use Torque; Torque had to generate
oracle TIMESTAMP (instead of DATE) for all the jdbc columns DATE, TIME
and TIMESTAMP. I look in torque-3.0.2 archive, find a file name in
db.props in sql/base/oracle change the 3 lines and update jar with jar
tool. Torque now generates TIMESTAMP (according to 9i specifications)
for DATE, TIME and TIMESTAMP jdbc types. I don't think that torque
project can accept such a workaround...  job to have something clean
is bigger than that !!

Jdbc works now as before 9.2, with java.sql.timestamp, authorizing
comparisons and hours access on all java types... That's what we need
all !!

Regards to all posting here ;-)

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



RE: Mapping question

2005-03-03 Thread Günther Wieser
i tried to change my code to using extends, it works perfect for me, and
from an object oriented design view, this is perfect!

what i did (if i apply the things i did to georgs problem):

- create an abstract class Address that has all attributes in it
- derive both classes HomeAddress and WorkAddress from Address
- setup the constructor of both classes as described in
 
http://db.apache.org/ojb/docu/guides/advanced-technique.html#Extents+and+Pol
ymorphism
- setup the repository.xml as described in the chapter
 
http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+All+Cla
sses+on+the+Same+Table

this works perfect for me and is much cleaner (but of course works only if
you can change your db layout).
if you can't change the layout, one possible solution is described in
 
http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+All+Cla
sses+on+the+Same+Table
when showing how to implement your own ClassDescriptor. cool stuff!

kr,
guenther


-Original Message-
From: Georg Müller [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 11:33 PM
To: OJB Users List
Subject: Re: Mapping question

Thomas Dudziak wrote:
 As far as I understand he wants to use a reference that refers to a 
 class with a compound primarykey, where one of the foreignkey values 
 is fixed:
 
 reference-descriptor name=homeAddress
   class-ref=Address
   auto-update=true
   auto-delete=true
   foreignkey field-ref=login /
   foreignkey expression=heimat /
   !-- the second part of the fk relating to pk part 'type', is fixed 
 to heimat -- /reference-descriptor
 

Yes, that is what I am searching for.

-
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

2005-03-03 Thread Georg Müller
I now have a running version, but the way Thomas proposed would be much 
nicer.

I have added a collection descriptor
collection-descriptor
  name=addresses
  element-class-ref=Adress
  auto-update=true
  auto-delete=true
  inverse-foreignkey field-ref=login/
/collection-descriptor
and he returns both addresses.
I tried to modify my getters and setters for addresses to set 
homeAddress and workAddress, but I tested this and noticed that they are 
not invoked (why should they? (*grml*))

So I added a function assignAddresses(), which is invoked by the DAO 
getUser method.

public void addressAssignment() {

  Iterator i = this.adresses.iterator();
  while (i.hasNext()) {
Adress address = (Address) i.next();
if (home.equals(adress.getType()))
  this.homeAddress = address;
if (work.equals(adress.getType()))
  this.workAddress = address;
  }
}
Now I have to take care that every setHomeAddress also modifies the 
collection (because I don't think that getAddresses() is invoked by ojb 
either ;) )

May be I implement a query costomizer who filters the addresses like 
described in the advanced mapping tutorial:

collection-descriptor
  name=homeAddressCollection
  element-class-ref=Address
  auto-update=true
  auto-delete=true
  inverse-foreignkey field-ref=login/
  query-customizer
   class=AddressQueryCustomizer
attribute attribute-name=type attribute-value=home /
  /query-customizer
/collection-descriptor
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Pooling questions

2005-03-03 Thread Robert r. Sanders
I have had problems with pooling in the past; currently I have an OJB 
based app running (against a MySQL db) using the following pooling:

connection-pool
   maxActive=30
   maxIdle=30
   maxWait=1500
   whenExhaustedAction=1
   testOnBorrow=true
   testOnReturn=false
   testWhileIdle=true
   timeBetweenEvictionRunsMillis=1
   numTestsPerEvictionRun=2
   validationQuery=SHOW TABLES /

Vincent Frison wrote:
Hi all,
I have sometimes troubles with pooling. One of the most frequent exception is:
An action has failed: Borrow broker from pool failed, using PBKey 
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null, password=null

It seems that I explode the broker pool capacity (altough I close brokers as 
soon as possible). I'm not very familiar with pooling so please don't blame 
me. My poor brain can just understand that there is two different pools: one 
for the OJB brokers and optionally another one for the JDBC connections. 
Okay. But there is a lot of points which are very dark.

1) Configuring the PB pool
The default values in OJB.properties looks very strange for me:
maxIdle=-1
timeBetweenEvictionRunsMillis=-1
If I read the comments, there's no limit and no eviction for idle brokers, so 
it it sounds for me that they can grow indefinitely (even if 
whenExhaustedAction != 2)! Or maybe the maxActive value limits idle brokers 
too?

2) Configuring the JDBC connections pool
a) Regarding to OJB:
Depending on how OJB brokers handles JDBC connections, is there any rules to 
respect when configuring this the pools, e.g. PB pool maxActive  JDBC pool 
maxActive? I guess this is not mandatory since OJB brokers use JDBC 
connection factory (which could not use pooling btw) and close connections 
properly, but i'd like to be sure..

b) jndi-datasource-name vs. connection-pool:
I use OJB within Tomcat 5.0.x and I have a JNDI DataSource defined in Tomcat 
(DBCP Factory). If I want to use it with OJB, I have to declare it in the 
jndi-datasource-name attribute of jdbc-connection-descriptor. In this 
case does it mean that OJB don't manage the pool itself and that the 
connection-pool declaration will be ignored? Is the 
ConnectionFactoryDBCPImpl mandatory in that case? Apparently it works better 
if I use it (compared to ConnectionFactoryPooledImpl). But if a JNDI 
DataSource - which is not implemented with DBCP - is declared in my 
container, should I stay with the default implementation?

Thanks a lot..
Vinz
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

--
   Robert r. Sanders
   Chief Technologist
   iPOV
   (334) 821-5412
   www.ipov.net
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]