Hi folks,
OpenJPA always return a OpenJPAId when I call the
PersistenceUtil#getIdentifier, but it no make sense IMHO.
E.g:
If I have an Entity that my ID is String type.
@Entity
class xpto {
@Id
private String id;
...
}
The spec say:
"Return the id of the entity. A generated id is not guaranteed to be
available until after the database insert has occurred. Returns null if the
entity does not yet have an id."
This case, the impl should return the type declared in Entity. Right?
So, PersistenceUtil#getIdentifier should return a String value, but OpenJPA
return an StringId (StringID extends OpenJPAId).
I attached an patch, but.. I don't know if this is enough.
https://issues.apache.org/jira/browse/OPENJPA-2590
Thank you for attention!
On Mon, May 25, 2015 at 12:48 PM, Kevin Sutter <[email protected]> wrote:
> Hi Daniel,
> Yes, that would be correct. If you need to get the exact type as defined
> by your entity class, then you would need to go another level deeper. Just
> to correct the link for anybody that is referencing this posting:
>
> https://github.com/apache/openjpa/blob/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
>
> Kevin
>
> On Sun, May 24, 2015 at 11:58 PM, Daniel Cunha <[email protected]>
> wrote:
>
> > Hi Folks,
> >
> > I have a doubt.
> > This method (PersistenceUnitUtil#getIdentifier) should return the value
> of
> > id, right?
> > OpenJPA return a instance of OpenJPAId [StringId, LongId, BigDecimalId
> and
> > etc ]
> >
> > This case, when ID is OpenJPAId, we need to call OpenJPAId#getIdObject
> > here:
> >
> >
> https://github.com/apache/openjpa/blob/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java#L361-L363
> > no?
> >
> >
> > --
> > Best regard,
> > Daniel Cunha (soro)
> >
>
--
Best regard,
Daniel Cunha (soro)