-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Retrieving the unsaved-value of an entity
PostPosted: Tue Oct 02, 2007 5:36 am 
Newbie

Joined: Thu Aug 02, 2007 11:20 am
Posts: 4
Hibernate version: v1.2.0GA

Hi,

@ the mo I have the following guard clause on my Retrieve by Id method (TPersistableObject & TId are generic params):

Code:
public TPersistableObject TryToGetById(TId id)
        {
            #region Guards

            if (id.Equals(default(TId))) return null;

            #endregion

            return Session.Get<TPersistableObject>(id);
        }

This works fine when the unsaved-value of the identifier is indeed default(TId). However I am now dealing with a legacy database that has some entities that have an unsaved-value that is not default(TId)

...Is there any way that I can return the unsaved value of an identifier for an entity.

N.B. I had originally intended on using the EntityMetamodel property of the AbstractEntityPersister but alas it is a protected property so I can't get access to it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.