You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Thoralf Rickert <th...@cadooz.de> on 2005/11/25 10:51:21 UTC

Torque with Java5 features

Hi!

I'm not sure, if this feature was discussed already on this list, but
how big is the chance, that torque supports the Java5 features, like
generics, in a future version? I know that this means a lot of work and
much trouble with users, who aren't able to use Java5 because of some
restrictions or what ever. But it has some very useful addons. For
example a generated doSelect could return a List<TableA>. That makes
runtime errors - because of wrong class casts - obsolete.

After Sun's launch of the Java5 version, I had changed most of the class
generation templates in torque 3.1 (object,peer,map) to use this
features in our whole application without any breakage (til
BasePeer...). That tooks me 4-5 hours and wasn't really complicated. But
it's practically a branch, because older Java compiler aren't able to
compile this generated classes. And I know it's not useful to maintain
two source tree for pre Java5 and Java5.

I think it could be possible to create templates that are able to
generate preJava5 and Java5 version by using a switch in the
configuration. For example a switch called torque.java5, which could be
true or false could be used to output the best java source code. For
example:

public static java.util.List#if($torque.java5)<${table.JavaName}>#end
    doSelect(Criteria criteria) throws org.apache.torque.TorqueException
{
  return populateObjects(doSelectVillageRecords(criteria));
}

It's not nice, but it could work. The other part (converting the
generator and the runtime libraries) is another problem... 

But for now I'm just asking, if this is on your plan?

bye
Thoralf




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: Torque and Spring integration

Posted by Thomas Fischer <tf...@apache.org>.
Hi,

Sorry I did not respond to your first message, but I was quite busy at 
work and doing the 3.2 release for Torque.

I do not have sufficient knowledge (i.e. basically no knowledge) about 
spring to judge whether the integration is complete, but the API you 
describe below does look reasonable to me. Sorry I do not have the time 
and energy to delve further into your work.

Please feel free to advertise your integration also at the Torque users 
list. Thinking about it, we should add a link at the Torque home page, 
too. Keep nagging me about this if I forget it.

     Thomas



On Mon, 28 Nov 2005 jmenke@chubb.com wrote:

> We have developed a simple wrapper for Torque that allows integration with
> the Spring Framework.  By using it, you get some support for Generics.
>
> https://torque-spring.dev.java.net/
>
> Currently we support a simple set of methods.
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> package org.springmodules.orm.torque;
>
> import java.util.List;
>
> import org.apache.torque.om.BaseObject;
>
> public interface TorqueExternalOperations extends TorqueOperations {
>
>  <T extends BaseObject> T create(Class<T> torqueObjectClass) throws
> TorqueSpringException;
>
>  <T extends BaseObject> List<T> find(Class<T> torqueObjectClass, int[]
> ids) throws TorqueSpringException;
>
>  <T extends BaseObject> T find(Class<T> torqueObjectClass, int id) throws
> TorqueSpringException;
>
>  <T extends BaseObject> void remove(T persistableObject) throws
> TorqueSpringException;
>
>  <T extends BaseObject> void save(T persistableObject) throws
> TorqueSpringException;
>
>  <T extends BaseObject> T copy(final T object) throws
> TorqueSpringException;
>
> }
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Note  this framework it is not replacement for torque
> it is just adds extra functionality typical for springframework.
>
> We are looking for reviews/suggestions for expansion/improvement  any peer
> review would be appreciated.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: Torque with Java5 features

Posted by jm...@chubb.com.
We have developed a simple wrapper for Torque that allows integration with 
the Spring Framework.  By using it, you get some support for Generics. 

https://torque-spring.dev.java.net/

Currently we support a simple set of methods.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 

 package org.springmodules.orm.torque;

import java.util.List;

import org.apache.torque.om.BaseObject;

public interface TorqueExternalOperations extends TorqueOperations {

  <T extends BaseObject> T create(Class<T> torqueObjectClass) throws 
TorqueSpringException;

  <T extends BaseObject> List<T> find(Class<T> torqueObjectClass, int[] 
ids) throws TorqueSpringException;

  <T extends BaseObject> T find(Class<T> torqueObjectClass, int id) throws 
TorqueSpringException;

  <T extends BaseObject> void remove(T persistableObject) throws 
TorqueSpringException;

  <T extends BaseObject> void save(T persistableObject) throws 
TorqueSpringException;

  <T extends BaseObject> T copy(final T object) throws 
TorqueSpringException;

}

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Note  this framework it is not replacement for torque
it is just adds extra functionality typical for springframework.

We are looking for reviews/suggestions for expansion/improvement  any peer 
review would be appreciated.

Re: Torque with Java5 features

Posted by Thomas Fischer <fi...@seitenbau.net>.



Hi,

Just to make sure that I understood you correctly: You were able to convert
the templates without chamnging the Runtime jar, and it worked ?
If this is done, this would be the way to go. The only way I see supporting
Java 1.4 and and Java 1.5 in the generator and runtime jars except not
using the 1.5 features there.

Some comments (all IMHO):
- Testing would be more complicated. At the moment, it is already a
nuisance to change the databases by hand, and to change the idtable
property by hand. To not spend my life testing, I do admit I usually do not
switch other parameters. So this would add another parameter to be
switched; this gets to a point where something atomatic would have to be
written.
- We already have too many generator parameters. We need to think about
that problem. But I would guess in this case, a configuration parameter
would be the only sensible way (maintaining two sets of templates, with
managers and withou them, is a nuisance already, I would not want another
split)
- In my eyes, it is certainly a nice feature, but it is not the first in my
personal list of priorities for after 3.2. I would support it if it would
be done, but I would not do it myself.

     Thomas

"Thoralf Rickert" <th...@cadooz.de> schrieb am 25.11.2005
10:51:21:

> Hi!
>
> I'm not sure, if this feature was discussed already on this list, but
> how big is the chance, that torque supports the Java5 features, like
> generics, in a future version? I know that this means a lot of work and
> much trouble with users, who aren't able to use Java5 because of some
> restrictions or what ever. But it has some very useful addons. For
> example a generated doSelect could return a List<TableA>. That makes
> runtime errors - because of wrong class casts - obsolete.
>
> After Sun's launch of the Java5 version, I had changed most of the class
> generation templates in torque 3.1 (object,peer,map) to use this
> features in our whole application without any breakage (til
> BasePeer...). That tooks me 4-5 hours and wasn't really complicated. But
> it's practically a branch, because older Java compiler aren't able to
> compile this generated classes. And I know it's not useful to maintain
> two source tree for pre Java5 and Java5.
>
> I think it could be possible to create templates that are able to
> generate preJava5 and Java5 version by using a switch in the
> configuration. For example a switch called torque.java5, which could be
> true or false could be used to output the best java source code. For
> example:
>
> public static java.util.List#if($torque.java5)<${table.JavaName}>#end
>     doSelect(Criteria criteria) throws org.apache.torque.TorqueException
> {
>   return populateObjects(doSelectVillageRecords(criteria));
> }
>
> It's not nice, but it could work. The other part (converting the
> generator and the runtime libraries) is another problem...
>
> But for now I'm just asking, if this is on your plan?
>
> bye
> Thoralf
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org