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 <[email protected]>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 <[email protected]> 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 > > <[email protected]>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 <[email protected] > > > >> 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*
