Hi, sometime ago I've tried cayenne JPA [1] and that time I couldn't
touch POJO source code.
Now this is a personal learning and I want do the cayenne way.
So trying Andrus advices:
1 reverse engineer the DB in question with CayenneModeler
2 manually tweak the model to match the property names in the existing
POJO Java classes
3 Run class generator to generate the _Xyz superclasses.
4 Change the existing classes by hand to inherit from _Xyz counterpart.
5 Remove existing persistence fields, and use superclass getters and
setters to access them. * Change the API throughout the code to use
Cayenne ObjectContext and Queries.
I've stopped on 4 when I saw the source generated
(osu-park/src/main/resources/codigo). The class inheritance looks a
little odd.
While testing my original code I do this
(osu-park/src/test/java/park/model/party/PessoaTest.java):
[code]
public class PessoaTest {
..est
public final void testPessoaFisica() {
Pessoa p;
p = new PessoaFisica(1, "Gilberto", "F", "Endereço",
Date.valueOf("2009-01-01"), "RG", "CPF");
assertNotNull(p);
}
..est
public final void testPessoaJuridica() {
Pessoa p;
p = new PessoaJuridica(1, "Souza e cia", "J", "Endereço",
Date.valueOf("2009-01-01"), "CNPJ");
assertNotNull(p);
}
}
[/code]
How would it be with the new generated code? I think I need a good reference!
Thanks,
Gilberto C. Andrade
blog.gilbertoca.com
[1]http://markmail.org/message/ijogqds67xhkri2u
This archive was generated by hypermail 2.0.0 : Fri Aug 07 2009 - 14:58:02 EDT