isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lechner Andreas <alech...@at.focusmr.com>
Subject Re: persist a new Object
Date Thu, 12 Mar 2015 09:28:27 GMT
Hi Martin,

everytime when I use JDOHelper.getObjectId on my stored Object
after container.persistIfNotAlready 
I get a NULL value.

The instance of PersistenceCapable is true.

best regards
Andreas



----- Ursprüngliche Mail -----
Von: "Martin Grigorov" <mgrigorov@apache.org>
An: "users" <users@isis.apache.org>
Gesendet: Mittwoch, 11. März 2015 17:07:30
Betreff: Re: persist a new Object

Hi,

I think you need something like:

if (!(this instanceof javax.jdo.spi.PersistenceCapable)) {
return null;
}
OIDImpl longIdentity = (OIDImpl) JDOHelper.getObjectId(this);
return longIdentity.getKeyValue();

Martin Grigorov
Funemployed! Available for hire!
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Mar 11, 2015 at 5:58 PM, Lechner Andreas <alechner@at.focusmr.com>
wrote:

> Hi all,
>
> Maybe i have overseen something.
>
> I want to persist MyObject.
> It has a member ID which is a @PrimaryKey and @Persistent(valueStrategy =
> IdGeneratorStrategy.IDENTITY).
>
> When id do:
> PersistenceManager jdoPersistenceManager =
> isisJdoSupport.getJdoPersistenceManager();
> MyObject persistedObject = jdoPersistenceManager.makePersistent(myObject);
>
> I get an ID filled in the returned persistedObject.
>
> How do i get the ID of the fresh persisted MyObject when I use the
> injected DomainObjectContainer container?
> container.persistIfNotAlready(settingItem);
>
> I need the ID and want to use the implemented soloution from Apache ISIS
> and not to
> implement my own soloution.
>
> best regards
> Andreas
>

Mime
View raw message