You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Alexander Saint Croix <sa...@gmail.com> on 2008/01/13 01:07:57 UTC
Panaki: your blog entry on persisting a generic graph
Panaki,
I read your blog entry on persisting a generic graph and am very interested
in using something similar to this for some of my entities.
The pattern I'm looking to do is something like the following:
@MappedSuperclass
> public abstract class Foo implements Serializable {
> @Id
> private long id;
>
> public long getId() { return id; }
> public void setId(long id) { this.id = id; }
>
> public void doStuff() {
> // stuff. very abstract, to be sure.
> }
> }
>
> @Entity
> public class ConcreteFoo extends Foo {
> public void doConcreteStuff() {
> // more concrete stuff
> }
> }
>
> @Entity
> public class OtherFoo extends Foo {
> public void doOtherStuff() {
> // more concrete stuff
> }
> }
>
> @Entity
> public class Funk<F extends Foo> {
> private F foo;
>
> public F getFoo() { return foo; }
>
> public void setFoo(F foo) { this.foo = foo; }
> }
>
The idea would be to allow client code to create "new Funk<ConcreteFoo>()"
and work with the class in a simpler fashion. (think Foo == Party,
ConcreteFoo == Person, OtherFoo == Organization and Funk ==
PartyRelationship for more of a sense what I'm going for here.)
Does this make sense and is it possible? In your blog entry you mention the
@Type annotation. Can't find references to it anywhere so thought I'd ask
the expert.
Cheers!
--
Alexander R. Saint Croix
Re: Panaki: your blog entry on persisting a generic graph
Posted by Alexander Saint Croix <sa...@gmail.com>.
Dead thread. The @Type annotation is defined in
org.apache.openjpa.persistence.Type
--
Alex
On Jan 12, 2008 6:07 PM, Alexander Saint Croix <sa...@gmail.com>
wrote:
> Panaki,
>
> I read your blog entry on persisting a generic graph and am very
> interested in using something similar to this for some of my entities.
>
> The pattern I'm looking to do is something like the following:
>
> @MappedSuperclass
> > public abstract class Foo implements Serializable {
> > @Id
> > private long id;
> >
> > public long getId() { return id; }
> > public void setId(long id) { this.id = id; }
> >
> > public void doStuff() {
> > // stuff. very abstract, to be sure.
> > }
> > }
> >
> > @Entity
> > public class ConcreteFoo extends Foo {
> > public void doConcreteStuff() {
> > // more concrete stuff
> > }
> > }
> >
> > @Entity
> > public class OtherFoo extends Foo {
> > public void doOtherStuff() {
> > // more concrete stuff
> > }
> > }
> >
> > @Entity
> > public class Funk<F extends Foo> {
> > private F foo;
> >
> > public F getFoo() { return foo; }
> >
> > public void setFoo(F foo) { this.foo = foo; }
> > }
> >
>
> The idea would be to allow client code to create "new Funk<ConcreteFoo>()"
> and work with the class in a simpler fashion. (think Foo == Party,
> ConcreteFoo == Person, OtherFoo == Organization and Funk ==
> PartyRelationship for more of a sense what I'm going for here.)
>
> Does this make sense and is it possible? In your blog entry you mention
> the @Type annotation. Can't find references to it anywhere so thought I'd
> ask the expert.
>
> Cheers!
> --
> Alexander R. Saint Croix
>
>