|
Re: Teneo/Hibernate NonUniqueObjectException resolving [message #427519 is a reply to message #427492] |
Thu, 19 February 2009 19:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Mikhail,
For virtual/synthetic id's Teneo keeps the Id's in a separate cache. So you can also do this:
Serializable id = (Serializable) IdentifierCacheHandler.getInstance().getID(object);
Note that for live/production software it is recommended to have a real id-attribute and not to use synthetic id's.
gr. Martin
Mikhail Kadan wrote:
> I have next method:
>
> public static Serializable getId(Session session, Object object) {
> Serializable id = null;
> try {
> session.lock(object, LockMode.NONE);
> id = session.getIdentifier(object);
> } catch (NonUniqueObjectException e) {
> throw new RuntimeException(e);
> } catch (TransientObjectException e2) {
> id = session.save(object);
> }
> return id;
> }
>
> I want to change catcher for NonUniqueObjectException to return valid
> value, not just chain exception on top level. I have to return my
> object's id:
>
> id = object.getId();
>
> But as I understand Teneo adds id field dynamically, and I don't have it
> in EMF model, so I cannot access it in a regular way. How can I get id
> of my object in this situation?
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03807 seconds