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 Wed, 20 Feb 2013 01:07:37 GMT
I am using version 2.2.1 and it didn't help by moving the initialization logic into the constructor.

I think the issue I'm facing is that the entity is currently "detached."  However, just because
the object is detached doesn't mean it doesn't have an identity (at least not in my case).
 Is this a bug?
  

On Feb 19, 2013, at 5:12 PM, Rick Curtis <curtisr7@gmail.com> wrote:

> For giggles, what happens if you add a constructor and set the value in
> there? Also, what version of OpenJPA are you on?
> 
> 
> On Tue, Feb 19, 2013 at 2:11 PM, James Carman
> <jcarman@carmanconsulting.com>wrote:
> 
>> 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?
>>> 
>> 
>> 
> 
> 
> -- 
> *Rick Curtis*


Mime
View raw message