You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Dain Sundstrom <da...@iq80.com> on 2007/02/01 19:55:25 UTC

Unknown primary key

Does JPA or OpenJPA have support for what is called unknown primary  
key in the EJB CMP 2.0 spec.  An unknown primary key is the pk of an  
entity bean that does not have a field (or abstract getter/setter)  
for a primary key.  Instead the framework adds a virtual field to the  
bean that contains the primary key.  The bean can get access to the  
primary key instance calling "Object EntityContext.getPrimaryKey()".   
Typically, the unknown primary key is implemented using database  
identity and a java.lang.Long.

I can add a real field to the class via byte code transformation for  
CMP1 entity beans, but would perfer not to.  For CMP2, I'm already  
generating a subclass so I already have a place to put the field.

Thanks,

-dain

Re: Unknown primary key

Posted by Abe White <aw...@bea.com>.
> Sadly, not currently. OpenJPA domain model extensions are not  
> currently
> available in XML form. See OPENJPA-87 for a related issue.

While this is true, I believe if you just don't declare any @Id  
fields we'll probably default to datastore identity automatically.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

RE: Unknown primary key

Posted by Patrick Linskey <pl...@bea.com>.
Sadly, not currently. OpenJPA domain model extensions are not currently
available in XML form. See OPENJPA-87 for a related issue.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Dain Sundstrom [mailto:dain@iq80.com] 
> Sent: Thursday, February 01, 2007 11:47 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Re: Unknown primary key
> 
> This looks good, but in my case I can't annotate the classes.  Is  
> there a way to specify this via XML or a property?
> 
> -dain
> 
> On Feb 1, 2007, at 11:42 AM, Patrick Linskey wrote:
> 
> > Yes, you can do this:
> > http://incubator.apache.org/openjpa/docs/latest/manual/ 
> > manual.html#ref_g
> > uide_pc_oid_datastore
> >
> > -Patrick
> >
> > -- 
> > Patrick Linskey
> > BEA Systems, Inc.
> >
> > 
> ______________________________________________________________
> ________ 
> > _
> > Notice:  This email message, together with any attachments, may  
> > contain
> > information  of  BEA Systems,  Inc.,  its subsidiaries  and   
> > affiliated
> > entities,  that may be confidential,  proprietary,  copyrighted   
> > and/or
> > legally privileged, and is intended solely for the use of the  
> > individual
> > or entity named in this message. If you are not the intended  
> > recipient,
> > and have received this message in error, please immediately return  
> > this
> > by email and then delete it.
> >
> >> -----Original Message-----
> >> From: Dain Sundstrom [mailto:dain@iq80.com]
> >> Sent: Thursday, February 01, 2007 10:55 AM
> >> To: open-jpa-dev@incubator.apache.org
> >> Subject: Unknown primary key
> >>
> >> Does JPA or OpenJPA have support for what is called unknown primary
> >> key in the EJB CMP 2.0 spec.  An unknown primary key is 
> the pk of an
> >> entity bean that does not have a field (or abstract getter/setter)
> >> for a primary key.  Instead the framework adds a virtual
> >> field to the
> >> bean that contains the primary key.  The bean can get access to the
> >> primary key instance calling "Object
> >> EntityContext.getPrimaryKey()".
> >> Typically, the unknown primary key is implemented using database
> >> identity and a java.lang.Long.
> >>
> >> I can add a real field to the class via byte code 
> transformation for
> >> CMP1 entity beans, but would perfer not to.  For CMP2, I'm already
> >> generating a subclass so I already have a place to put the field.
> >>
> >> Thanks,
> >>
> >> -dain
> >>
> 
> 

Re: Unknown primary key

Posted by Dain Sundstrom <da...@iq80.com>.
This looks good, but in my case I can't annotate the classes.  Is  
there a way to specify this via XML or a property?

-dain

On Feb 1, 2007, at 11:42 AM, Patrick Linskey wrote:

> Yes, you can do this:
> http://incubator.apache.org/openjpa/docs/latest/manual/ 
> manual.html#ref_g
> uide_pc_oid_datastore
>
> -Patrick
>
> -- 
> Patrick Linskey
> BEA Systems, Inc.
>
> ______________________________________________________________________ 
> _
> Notice:  This email message, together with any attachments, may  
> contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and   
> affiliated
> entities,  that may be confidential,  proprietary,  copyrighted   
> and/or
> legally privileged, and is intended solely for the use of the  
> individual
> or entity named in this message. If you are not the intended  
> recipient,
> and have received this message in error, please immediately return  
> this
> by email and then delete it.
>
>> -----Original Message-----
>> From: Dain Sundstrom [mailto:dain@iq80.com]
>> Sent: Thursday, February 01, 2007 10:55 AM
>> To: open-jpa-dev@incubator.apache.org
>> Subject: Unknown primary key
>>
>> Does JPA or OpenJPA have support for what is called unknown primary
>> key in the EJB CMP 2.0 spec.  An unknown primary key is the pk of an
>> entity bean that does not have a field (or abstract getter/setter)
>> for a primary key.  Instead the framework adds a virtual
>> field to the
>> bean that contains the primary key.  The bean can get access to the
>> primary key instance calling "Object
>> EntityContext.getPrimaryKey()".
>> Typically, the unknown primary key is implemented using database
>> identity and a java.lang.Long.
>>
>> I can add a real field to the class via byte code transformation for
>> CMP1 entity beans, but would perfer not to.  For CMP2, I'm already
>> generating a subclass so I already have a place to put the field.
>>
>> Thanks,
>>
>> -dain
>>


RE: Unknown primary key

Posted by Patrick Linskey <pl...@bea.com>.
Yes, you can do this:
http://incubator.apache.org/openjpa/docs/latest/manual/manual.html#ref_g
uide_pc_oid_datastore

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Dain Sundstrom [mailto:dain@iq80.com] 
> Sent: Thursday, February 01, 2007 10:55 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Unknown primary key
> 
> Does JPA or OpenJPA have support for what is called unknown primary  
> key in the EJB CMP 2.0 spec.  An unknown primary key is the pk of an  
> entity bean that does not have a field (or abstract getter/setter)  
> for a primary key.  Instead the framework adds a virtual 
> field to the  
> bean that contains the primary key.  The bean can get access to the  
> primary key instance calling "Object 
> EntityContext.getPrimaryKey()".   
> Typically, the unknown primary key is implemented using database  
> identity and a java.lang.Long.
> 
> I can add a real field to the class via byte code transformation for  
> CMP1 entity beans, but would perfer not to.  For CMP2, I'm already  
> generating a subclass so I already have a place to put the field.
> 
> Thanks,
> 
> -dain
>