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, 12 Mar 2013 11:21:26 GMT
I haven't had a chance to get around to this.  I switched back to Hibernate, since they support
this out of the box and I had to get something working.

I don't think it's necessary to have an attached entity in order to determine the identifier
of that entity, especially if I am not using generators or anything and I'm providing the
identifier myself.  The metadata (annotations in this case) should be enough to tell you how
to return the identifier.


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

> Please create a simple unit test and I'll try to take a look tomorrow.
> 
> 
> On Tue, Feb 19, 2013 at 7:07 PM, James Carman
> <jcarman@carmanconsulting.com>wrote:
> 
>> 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*
>> 
>> 
> 
> 
> -- 
> *Rick Curtis*


Mime
View raw message