cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilberto C. Andrade" <>
Subject Cayenne POJO inheritance
Date Fri, 07 Aug 2009 18:57:18 GMT
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
public class PessoaTest {

	public final void testPessoaFisica() {
		Pessoa p;
		p = new PessoaFisica(1, "Gilberto", "F", "Endere├žo",
Date.valueOf("2009-01-01"), "RG", "CPF");

	public final void testPessoaJuridica() {
		Pessoa p;
		p = new PessoaJuridica(1, "Souza e cia", "J", "Endere├žo",
Date.valueOf("2009-01-01"), "CNPJ");

How would it be with the new generated code? I think I need a good reference!


Gilberto C. Andrade


View raw message