openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <jcar...@carmanconsulting.com>
Subject Re: PersistenceUnitUtil.getIdentifier() Implementation...
Date Tue, 19 Feb 2013 20:11:59 GMT
The specification has:

/**
* 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.
* @param entity entity instance
* @return id of the entity
* @throws IllegalArgumentException if the
* to be an entity
*/

    public Object getIdentifier(Object entity);


So, the only time it's supposed to return null is when the entity does not have an id.  Am
I reading that correctly?

On Feb 19, 2013, at 2:45 PM, James Carman <jcarman@carmanconsulting.com> wrote:

> I'm having an issue where the getIdentifier() method is returning null on an entity with
the id set.  I have a class like this:
> 
> @MappedSuperclass
> public class UuidEntity
> {
> @Id
> private String id = UUID.randomUUID().toString();
> 
> }
> 
> My entities *always* have an id value.  Shouldn't getIdentifier() always return the value
of the "id" field?
> 


Mime
View raw message