openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ljnelson <ljnel...@gmail.com>
Subject Re: can JPA Entity extend non JPA Entity?
Date Thu, 01 Apr 2010 15:36:00 GMT

On Thu, Apr 1, 2010 at 10:56 AM, sapatel [via OpenJPA] <
ml-node+4837568-1347640927-210534@n2.nabble.com<ml-node%2B4837568-1347640927-210534@n2.nabble.com>
> wrote:

> What I want to do is I want all my JPA entities to extend some BaseEntity
> class where can I define some properites (which are not table columns) to
> use/share.


Just do it:

public class A {
  // no matter what you put in here it won't be mapped to the database,
  // even if you use JPA annotations.
}

@Entity
public class B extends A {
  // All state and behavior is available from A.  Only fields defined in B
that are
  // annotated with JPA annotations will get mapped to the database.
}

(If you want some of A's state to be mapped, then you want to look at the
@MappedSuperclass annotation, but that is not what you are claiming you want
from your question.)

Best,
Laird

-- 
View this message in context: http://n2.nabble.com/can-JPA-Entity-extend-non-JPA-Entity-tp4837568p4837820.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message