Just to confirm, what you are doing works without issue.

We are currently doing in production exactly what you are asking here. As 
Thomas states, due to erasure, the same types are being placed into your 
persistent objects.

As for mutating OJB to use generics -- there really isn't much benefit that can 
be derived. Almost none of the PB-API methods pass in a class object to 
specifiy the type (it is inside a Identity, or a Query), it cannot used to 
specifiy a typed Collection.

It's actually kind of nice -- we have a wrapper API around OJB that takes in a 
critieria and spits back out a collection, and with generics we are now able to 
'type' it.

So, what use to look like this:

List l = ps.findCollectionByCriteria(Foo.class, crit);
Iterator it = l.iterator;
while (it.hasNext(){
    Foo foo = (Foo)it.next();
    foo.bar();
}  

With typed generics, and class attributes now looks like this:

for (Foo foo: ps.findCollecionByCriteria(Foo.class, crit)){
   foo.bar();
}

Our API decleration for this method looks like this:

public <T extends BusinessObject> List<T> findCollectionByCriteria(Class<T> 
clazz, Criteria crit);

While there isn't as much stuff that can be done with OJB itself, it sure made 
our wrapper classes nicer.

-Andrew

> -----Original Message-----
> From: Edson Carlos Ericksson Richter 
> [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 08, 2005 3:14 PM
> To: OJB Users List
> Subject: Re: OJB 1.0.x and Java5.0
> 
> Let me expand my idea (sorry if I get boring).
> I have a User object. Each user has a LoginHour list. So, 
> using JDK 5.0 could I declare
> 
> public class User {
>   private String username;
>   private String password;
>   private List<LoginHour> loginHours;
>   public void setUsername(String newUsername) {...}
>   public String getUsername() {...}
>   public void setPassword(String newPassword) {...}
>   public Stirng getPassword() {...}
>   public void setLoginHours(List<LoginHour> loginHours) {
>     this.loginHours = loginHours;
>   }
>   public List<LoginHour> getLoginHours() {
>     return this.loginHours;
>   }
> }
> 
> And this will work fine? There is nothing to be changed on 
> class-descriptor, neihter in collection-descriptor?
> 
> 
> TIA,
> 
> Edson Richter
> 
> 
> Thomas Dudziak escreveu:
> 
> >On 8/8/05, Edson Carlos Ericksson Richter
> ><[EMAIL PROTECTED]> wrote:
> >  
> >
> >>Anyone has an example about how could OJB be used with 
> Generics? This
> >>will not affect the class-mapping descriptor?
> >>    
> >>
> >
> >Since Java generics will be compiled to non-generic bytecode, it does
> >not really affect classloading etc. Hence it should not matter when
> >running OJB, you simply specify the collection-descriptor etc. as you
> >would for non-generic code. The only differences are that 
> OJB does not
> >(yet) support enums, and that the XDoclet module might not work with
> >generic code (you'll at least need a CVS build of the XDoclet code to
> >be able to parse 1.5 code).
> >
> >Tom
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >  
> >
> 
> 
> -- 
> Edson Carlos Ericksson Richter
> MGR Informática Ltda.
> Fones: 3347-0446 / 9259-2993
> 
> 
> 

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

Reply via email to