ReverseMappingTool: easiest way to produce @MappedSuperclasses?

6 messages Options
Embed this post
Permalink
ljnelson

ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
Where in the customize(ClassMapping) method of ReverseCustomizer would I set
something that would let the code generators downstream know that they
should generate mapped superclasses instead of entities?

Would I install a different ClassStrategy on the mapping?

Thanks,
Laird
ljnelson

Re: ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
On Fri, Oct 23, 2009 at 10:32 AM, ljnelson [via OpenJPA] <[hidden email]> wrote:
Where in the customize(ClassMapping) method of ReverseCustomizer would I set
something that would let the code generators downstream know that they
should generate mapped superclasses instead of entities?
ljnelson

Re: ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
On Fri, Oct 23, 2009 at 10:54 AM, ljnelson [via OpenJPA] <[hidden email]> wrote:
On Fri, Oct 23, 2009 at 10:32 AM, ljnelson [via OpenJPA] <[hidden email]> wrote:
Where in the customize(ClassMapping) method of ReverseCustomizer would I set
something that would let the code generators downstream know that they
should generate mapped superclasses instead of entities?

I spoke too soon.  Setting this to true seems to eliminate all the useful length and nullability information from the resulting annotations.

So although instead of:

@Entity
@Table(name = "foo")
public class Foo ... {
  @Basic
  @Column(nullable = false, length = 4)
  private String bar;

}

I get

@MappedSuperclass
@Table
public class Foo ... {
  @Basic
  private String bar;

}

I guess I'll keep looking.

Laird
ljnelson

Re: ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
On Fri, Oct 23, 2009 at 11:05 AM, ljnelson [via OpenJPA] <[hidden email]> wrote:
I spoke too soon.  Setting this to true seems to eliminate all the useful length and nullability information from the resulting annotations.
Pinaki Poddar

Re: ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
Hi Laird,
  Which version of OpenJPA you are on?
  Why I ask is if you are on trunk, then MappedSuperclass is represented in ClassMetaData.setAbstract().
ReverseCustomizer should set ClassMetaData.setAbstract(true) and annotation builder getEntityType() requires to check isAbstract() to return MappedSuperclass.

  Regards --

Pinaki

ljnelson wrote:
On Fri, Oct 23, 2009 at 11:05 AM, ljnelson [via OpenJPA] <
ml-node+3879262-1760251060@n2.nabble.com<ml-node%2B3879262-1760251060@n2.nabble.com>
> wrote:

> I spoke too soon.  Setting this to true seems to eliminate all the useful
> length and nullability information from the resulting annotations.
>

JIRA filed: https://issues.apache.org/jira/browse/OPENJPA-1360

Best,
Laird
Pinaki
ljnelson

Re: ReverseMappingTool: easiest way to produce @MappedSuperclasses?

Reply Threaded More More options
Print post
Permalink
On Mon, Nov 2, 2009 at 1:45 AM, Pinaki Poddar [via OpenJPA] <[hidden email]> wrote:
Hi Laird,
  Which version of OpenJPA you are on?
  Why I ask is if you are on trunk, then MappedSuperclass is represented in ClassMetaData.setAbstract().
ReverseCustomizer should set ClassMetaData.setAbstract(true) and annotation builder getEntityType() requires to check isAbstract() to return MappedSuperclass.

Hi; no, unfortunately I'm on almost the bleeding edge, but not quite: 1.3.0-SNAPSHOT.

I found a way to do it involving a combination of setEmbeddedOnly(true) and various calls to syncMappingInfo (otherwise the fields get left off).

Thanks for the tip though; hopefully we'll move to 2.0 soon.

Best,
Laird