ojbdoclet task in ant build.xml

2003-12-31 Thread De Swert Pierre (GFDI)
I have reused the ant build files of the ojb-blank project to build my
own things. I have added a target to produce an ojb repository and a
project schema via ojb doclets, a target to generate the database by
means of torque (by the way, the repository.xml file is missing in the
ojb-blank project). But the result is not yet satisfactory. 
 
1.How to avoid editing the project-schema generated via ojb doclets?  I
have to replace http://jakarta.apache.org/turbine/dtd/database.dtd
http://jakarta.apache.org/turbine/dtd/database.dtd  with
src/schema/database.dtd, otherwise ...

   [torque-sql] Using contextProperties file:
E:\Workspaces\pds\myproject\build.properties
   [torque-sql] Using classpath
   [torque-sql] Generating to file
E:\Workspaces\pds\myproject\src\sql\report.myproject.sql.generation
   [torque-sql] Parsing file: 'myproject-schema.xml'
   [torque-sql] (transform.DTDResolver   140 ) Resolver:
usedhttp://jakarta.apache.org/turbine/dtd/database.dtd
   [torque-sql] (transform.DTDResolver   160 ) Couldn't read
DTD specified in XML schema: 
   [torque-sql] java.net.UnknownHostException: jakarta.apache.org
 
2. Is it possible to configure the ojbdoclet task to generate the ojb
repository and torque schema in to different directories?
 
3. Is it fitting to generate the ojb repository in src/resources and
torque schema in src/schema?
 
Many Thanks and happy New Year!
 
Pierre


Re: ojbdoclet task in ant build.xml

2003-12-31 Thread Thomas Dudziak

On Wed, 31 Dec 2003, De Swert Pierre (GFDI) wrote:

 I have reused the ant build files of the ojb-blank project to build my
 own things. I have added a target to produce an ojb repository and a
 project schema via ojb doclets, a target to generate the database by
 means of torque (by the way, the repository.xml file is missing in the
 ojb-blank project).

If you mean that the file generated by the XDoclet OJB module misses the
OJB core tables, then you are right, but this is on purpose. The module
only generates the repository_user.xml part (see the OJB unit tests for
the proposed structure of the repository xml files).

  
 1.How to avoid editing the project-schema generated via ojb doclets?  I
 have to replace http://jakarta.apache.org/turbine/dtd/database.dtd
 http://jakarta.apache.org/turbine/dtd/database.dtd  with
 src/schema/database.dtd, otherwise ...
 
[torque-sql] Using contextProperties file:
 E:\Workspaces\pds\myproject\build.properties
[torque-sql] Using classpath
[torque-sql] Generating to file
 E:\Workspaces\pds\myproject\src\sql\report.myproject.sql.generation
[torque-sql] Parsing file: 'myproject-schema.xml'
[torque-sql] (transform.DTDResolver   140 ) Resolver:
 usedhttp://jakarta.apache.org/turbine/dtd/database.dtd
[torque-sql] (transform.DTDResolver   160 ) Couldn't read
 DTD specified in XML schema: 
[torque-sql] java.net.UnknownHostException: jakarta.apache.org

This is a known problem with some XML parsers. There is an (for whatever
reason yet undocumented) attribute of the torque sub task called
'dtdUrl' that allows to specify the url of the dtd in the build file.

 2. Is it possible to configure the ojbdoclet task to generate the ojb
 repository and torque schema in to different directories?

Not easily (you can have paths in the destinationFile attributes if
you really want to). But you could generate them in some intermediate 
directory (e.g. build/schemas) and then move them to their designated
directories using ant tasks.

 3. Is it fitting to generate the ojb repository in src/resources and
 torque schema in src/schema?

Probably, but I generally avoid adding files to the src directory during
the build process but rather use an intermediate directory (build, target
or similar). Also during runtime you only need the repository xml
files. The torque schema is only required to initialize the database (via
ant task).

Tom



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



special form of join

2003-12-31 Thread Steffen Metzner
Hi List,

i want to joint to table in special way.
I have a Table TA mapped to a Class TA. No problem. But there is a need for a user to 
make a special search-input possible.
The used search criteria a elements of Table TB. In a normal way it is easy to make 
this possible:
SELECT ta.* FROM table_a ta, table_b tb where ta.element1 = tb.element1 and 
ta.element2 = tb.element2
So i want this in OJB. I just want objects from table A, but to find them i must joint 
them to table b. but i want no table B object.
I found one way to use SQL directly, but i think this is not a perfect way... maybe 
another way?  

greetings and a happy new year,
Steffen

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



RE: ojbdoclet task in ant build.xml

2003-12-31 Thread De Swert Pierre (GFDI)

 From: Thomas Dudziak [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, 31 December, 2003 11:12 AM
 To: OJB Users List
 Subject: Re: ojbdoclet task in ant build.xml
 
 On Wed, 31 Dec 2003, De Swert Pierre (GFDI) wrote:
 
  I have reused the ant build files of the ojb-blank project to build
my 
  own things. I have added a target to produce an ojb repository and a

  project schema via ojb doclets, a target to generate the database by

  means of torque (by the way, the repository.xml file is missing in
the 
  ojb-blank project).
 
 If you mean that the file generated by the XDoclet OJB module misses
the OJB core tables, then you are
 right, but this is on purpose. The module only generates the
repository_user.xml part (see the OJB unit 
 tests for the proposed structure of the repository xml files).

I mean that the src/resources directory of the ojb-blank project does
not contain a repository.xml file.
The src/resources directory contains the following files:

commons-logging.properties
log4j.properties
OJB.properties
repository.dtd
repository_database.xml
repository_ejb.xml
repository_internal.xml
repository_jdo.xml
repository_junit.xml
repository_junit_cloneable.xml
repository_junit_meta_seq.xml
repository_junit_model.xml
repository_junit_odmg.xml
repository_junit_otm.xml
repository_junit_reference.xml
repository_user.xml
simplelog.properties
spy.properties
testsuite-spy.properties

Maybe it does not contain the repository.xml file purposely or it could
be a build problem...

Pierre

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



Torque or OJB ?

2003-12-31 Thread Tiago Henrique Costa Rodrigues Alves

Which one is better , Torque or OJB? 
What are the main differences?


Tiago Henrique C. R. Alves


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



Re: ojbdoclet task in ant build.xml

2003-12-31 Thread Brian McCallister
On Dec 31, 2003, at 4:05 AM, De Swert Pierre (GFDI) wrote:

(by the way, the repository.xml file is missing in the
ojb-blank project)
Thanks for the heads up, I'll get a fix in today if I can replicate it.

-Brian



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


Re: ojbdoclet task in ant build.xml

2003-12-31 Thread Brian McCallister
Just checked in a modified build.xml which copies the repository.xml 
and ojbcore-schema.xml for the ojb-blank task.

-Brian

On Dec 31, 2003, at 9:08 AM, Brian McCallister wrote:

On Dec 31, 2003, at 4:05 AM, De Swert Pierre (GFDI) wrote:

(by the way, the repository.xml file is missing in the
ojb-blank project)
Thanks for the heads up, I'll get a fix in today if I can replicate it.

-Brian



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



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


Has anyone run OJB on WebLogic 8.1?

2003-12-31 Thread Bates, Alex

I tried following the instructions in the deployment documentation for OJB,
creating a startup class for WebLogic similar to the example posted on the
website.  

I'm getting an error that WL is unable to bind the factory to JNDI.  Then,
downstream of course I get errors that ojb/defaultODMG is not bound (we're
using the ODMG API).  

Here's the error binding to JNDI, and code for startup classes.  Am I doing
something wrong?  We are trying to port to WL 8.1 for an urgent customer
request, so any help is appreciated.



Info WLS Kernel  BEA-000287 Invoking startup class:
org.apache.ojb.weblogic.OjbODMGStartup.startup(null)
 
Info WebLogicServer wusab210009-0n9 myserver main WLS Kernel
 BEA-000288 org.apache.ojb.weblogic.OjbODMGStartup reports: Startup
Class error: impossible to bind OJB ODMG factory 



Here is the code:

public interface OjbODMGFactory extends ODMGJ2EEFactory, Serializable {

}


public class OjbODMGStartup implements OjbODMGFactory, T3StartupDef,
Serializable {

private String DEFAULT_JNDI_NAME = ojb/defaultODMG;
private String defaultPropsFile =
org/apache/ojb/weblogic/OJB.properties;

private T3ServicesDef services;

public void setServices (T3ServicesDef services)
{
this.services = services;
}

public Implementation getInstance()
{
return OJBJ2EE_2.getInstance();
}

public String startup (String name, Hashtable args)
throws Exception
{

try
{
String jndiName = (String)args.get (jndiname);
if (jndiName == null || jndiName.length () == 0)
jndiName = DEFAULT_JNDI_NAME;

String propsFile = (String)args.get (propsfile);
if (propsFile == null || propsFile.length () == 0)
{
System.setProperty(OJB.properties, defaultPropsFile  );
}
else
{
System.setProperty(OJB.properties, propsFile  );
}

InitialContext ctx = new InitialContext ();
bind (ctx, jndiName, this);

// return a message for logging
return Bound OJBODMGFactory to  + jndiName;
}
catch (Exception e)
{
e.printStackTrace();
// return a message for logging
return
Startup Class error: impossible to bind OJB ODMG
factory;
}
}

private void bind(Context ctx, String name, Object val)
throws NamingException
{
Name n;
for (n = ctx.getNameParser().parse(name);
 n.size()  1; n = n.getSuffix(1))
{
String ctxName = n.get(0);
try
{
ctx = (Context) ctx.lookup(ctxName);
}
catch (NameNotFoundException namenotfoundexception)
{
ctx = ctx.createSubcontext(ctxName);
}
}
ctx.bind(n.get(0), val);
}
}




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



RE: Has anyone run OJB on WebLogic 8.1?

2003-12-31 Thread Bates, Alex

Here is some more information: in stderr (wasn't present in the log file)
there is a NotSerializableException caused by the Ojb startup class.

As you can see from the code below, the startup class does implement
Serializable.  The only interface in OJB that it's implementing that is NOT
serializable is ODMGJ2EEFactory.  But if this were a problem I'm assuming it
would have been noticed by others.


Here is the NotSerializableException stack trace from WL:

javax.naming.CommunicationException.  Root exception is
java.rmi.UnmarshalExcept
ion: failed to unmarshal cookie; nested exception is:
java.io.NotSerializableException: weblogic.t3.srvr.T3ServerServices
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:294)
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:244)
at weblogic.jndi.internal.ServerNamingNode_811_WLStub.bind(Unknown
Sourc
e)
at weblogic.jndi.internal.WLContextImpl.bind(WLContextImpl.java:359)
at javax.naming.InitialContext.bind(InitialContext.java:355)
at
org.apache.ojb.weblogic.OjbODMGStartup.bind(OjbODMGStartup.java:89)
at
org.apache.ojb.weblogic.OjbODMGStartup.startup(OjbODMGStartup.java:58
)
at
weblogic.t3.srvr.StartupClassService.invokeStartup(StartupClassServic
e.java:177)


-Original Message-
From: Bates, Alex 
Sent: Wednesday, December 31, 2003 10:19 AM
To: OJB Users List
Subject: Has anyone run OJB on WebLogic 8.1?



I tried following the instructions in the deployment documentation for OJB,
creating a startup class for WebLogic similar to the example posted on the
website.  

I'm getting an error that WL is unable to bind the factory to JNDI.  Then,
downstream of course I get errors that ojb/defaultODMG is not bound (we're
using the ODMG API).  

Here's the error binding to JNDI, and code for startup classes.  Am I doing
something wrong?  We are trying to port to WL 8.1 for an urgent customer
request, so any help is appreciated.



Info WLS Kernel  BEA-000287 Invoking startup class:
org.apache.ojb.weblogic.OjbODMGStartup.startup(null)
 
Info WebLogicServer wusab210009-0n9 myserver main WLS Kernel
 BEA-000288 org.apache.ojb.weblogic.OjbODMGStartup reports: Startup
Class error: impossible to bind OJB ODMG factory 



Here is the code:

public interface OjbODMGFactory extends ODMGJ2EEFactory, Serializable {

}


public class OjbODMGStartup implements OjbODMGFactory, T3StartupDef,
Serializable {

private String DEFAULT_JNDI_NAME = ojb/defaultODMG;
private String defaultPropsFile =
org/apache/ojb/weblogic/OJB.properties;

private T3ServicesDef services;

public void setServices (T3ServicesDef services)
{
this.services = services;
}

public Implementation getInstance()
{
return OJBJ2EE_2.getInstance();
}

public String startup (String name, Hashtable args)
throws Exception
{

try
{
String jndiName = (String)args.get (jndiname);
if (jndiName == null || jndiName.length () == 0)
jndiName = DEFAULT_JNDI_NAME;

String propsFile = (String)args.get (propsfile);
if (propsFile == null || propsFile.length () == 0)
{
System.setProperty(OJB.properties, defaultPropsFile  );
}
else
{
System.setProperty(OJB.properties, propsFile  );
}

InitialContext ctx = new InitialContext ();
bind (ctx, jndiName, this);

// return a message for logging
return Bound OJBODMGFactory to  + jndiName;
}
catch (Exception e)
{
e.printStackTrace();
// return a message for logging
return
Startup Class error: impossible to bind OJB ODMG
factory;
}
}

private void bind(Context ctx, String name, Object val)
throws NamingException
{
Name n;
for (n = ctx.getNameParser().parse(name);
 n.size()  1; n = n.getSuffix(1))
{
String ctxName = n.get(0);
try
{
ctx = (Context) ctx.lookup(ctxName);
}
catch (NameNotFoundException namenotfoundexception)
{
ctx = ctx.createSubcontext(ctxName);
}
}
ctx.bind(n.get(0), val);
}
}




-
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: Find by ID in ODMG API?

2003-12-31 Thread Philippe Hacquin
... and they are much more efficient, too, because they use the cache. 
Using  an OQL query, even with the ID as criteria, will end up using a 
straight SQL query instead of looking up in the cache.

Sean Dockery wrote:
You can use PersistenceBroker Queries directly...

http://db.apache.org/ojb/faq.html#I%20donapos;t%20like%20OQL,%20can%20I%20use%20the%20PersistenceBroker%20Queries%20within%20ODMG?

Andreas Schildbach [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Is there a simple Find by ID call, instead of using a somewhat bloated
OQLQuery that only returns one result (and having to use an Iterator
just to get one object).
Something similar to Object Database.load(Class type, Object identity)
in the Castor API?


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


Re: objects in cache after transaction abort

2003-12-31 Thread Jair da Silva Ferreira Júnior
Hi Armin,

Thank you for your fast reply.

 hmm, this should not happend. Do you use checkpoint() or flush()
 in your code?
 This only could happens when the object was already in DB. Only the
 PersistenceBrokerImpl and RsIterator class push objects to cache.
 If you abort the tx, the PB instance is not aware of locked objects.

I use flush() and run an OJB query before aborting the transaction. I
don't use checkpoint().


 Interesting problem, please let me know if you can reproduce it.

I was able to reproduce the problem in the above test case. I hope it
helps:

  Transaction t=implementation.newTransaction();
  t.begin();
  PersistenceBroker broker=((HasBroker)t).getBroker();
  Student s=new Student();
  t.lock(s,t.WRITE);
  s.setName(student);
  s.setEmail([EMAIL PROTECTED]);
  s.setPassword(abcd);

  ((TransactionExt)t).flush();

  Criteria crit=new Criteria();
  crit.addEqualTo(_name,s.getName());

  QueryByCriteria query=QueryFactory.newQuery(Student.class,crit);

  Iterator it=broker.getIteratorByQuery(query);
  assertSame(s,it.next());
  assertFalse(it.hasNext());
  t.abort();

  t=implementation.newTransaction();
  t.begin();
  broker=((HasBroker)t).getBroker();
  QueryByIdentity query2=new QueryByIdentity(s);
  boolean cacheOk=(broker.getObjectByQuery(query2)==null);
  System.out.println(cacheOk: +cacheOk); //cacheOk==false always
  t.commit();

Thanks,
Jair Jr

 Jair da Silva Ferreira Júnior wrote:

  Hi,
  I am using ojb1.0_rc5, ODMG api with OJB queries, mysql4 (innodb
tables) in Linux Red Hat 7.3 (kernel 2.4.20-20.7).
  I moved from rc4 to rc5 recently and I noticed that sometimes the
objects persisted inside an aborted transaction are still in cache when
another transaction is started. Please, take a look at the above code to
better undestand what I am saying:
 
 Transaction t=implementation.newTransaction();
 t.begin();
 Person e=new Person();
 t.lock(e,t.WRITE);
 e.setName(some exam);
  t.abort();
 
  t=implementation.newTransaction();
 t.begin();
  PersistenceBroker broker=((HasBroker)t).getBroker();
 QueryByIdentity query=new QueryByIdentity(e);
 Person loaded=(Person)broker.getObjectByQuery(query);
 boolean cacheOk=(loaded==null); //here cacheOk==false sometimes
 t.commit();
 
 
  This problem does not happen everytime. So, sometimes cacheOk==true.
  I wasn't able to reproduce this problem in a test case, but it does
happen sometimes.
 
  This problem has never happened when I used rc4.
 
  Here's my cache configuration in OJB.properties:
 
 
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
  descriptorBasedCaches=false
 
  Thanks,
  Jair Jr
 



 -
 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: cache implementation change in rc5?

2003-12-31 Thread Jair da Silva Ferreira Júnior
Hi Armin,
Thank you very much for your fast reply.

 it's a(/my) bug in ObjectCacheDefaultImpl (rc5) causing this strange
 behaviour. I will check in a fixed version tomorrow.

Ok. How can I get the fixed ObjectCacheDefaultImpl implementation? Only
through CVS? Are you going to deploy a new rc5 binary version with this fix?

Thanks,
Jair Jr


 Jair da Silva Ferreira Júnior wrote:
  Hi,
  I am using ojb1.0_rc5, ODMG api with OJB queries, mysql4 (innodb
tables) in Linux Red Hat 7.3 (kernel 2.4.20-20.7).
  I moved from rc4 to rc5 recently and I noticed that sometimes when I
run a query the resulting associated objects don't come from the cache.
Please, take a look at the above code to better undestand what I am saying:
 
 Transaction t=implementation.newTransaction();
 t.begin();
 Person p=new Person();
 t.lock(p,t.WRITE);
 p.setName(somebody);
 Dog d=new Dog();
 t.lock(d,t.WRITE);
 d.setName(Spike);
 p.setDog(d);
 t.commit();
 
 t=implementation.newTransaction();
 t.begin();
 Criteria crit=new Criteria();
 crit.addEqualTo(_id,new Integer(p.getId()));
 QueryByCriteria query=QueryFactory.newQuery(Person.class,crit);
 PersistenceBroker broker=((HasBroker)t).getBroker();
 broker.removeFromCache(p);
 Person loaded=(Person)broker.getObjectByQuery(query);
 boolean cacheOk=(loaded.getDog()==d); //here cacheOk==false sometimes
 t.commit();
 
  The atributes (proxy, refresh, auto-retrieve, auto-update and
auto-delete) in the reference-descriptor for the association between Person
and Dog have default values. This way, refresh=false.
 
  This problem does not happen everytime. So, sometimes cacheOk==true.
  I wasn't able to reproduce this problem in a test case, but it does
happen sometimes.
 
  I've used rc4 for a long time and I've never had this kind of
problem.
 
  Here's my cache configuration in OJB.properties:
 
 
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
  descriptorBasedCaches=false
 
  Thanks,
  Jair Jr



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