openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nitish Kumar" <Nitish.Ku...@proteans.com>
Subject RE: hibernate conversion items
Date Sun, 22 Mar 2009 09:19:04 GMT

Hi James,
        I don't remember reading about any such API in OpenJpa (some body please correct me
if there is one), but getting that information should not be that difficult. I just wrote
a little API which would get you the information, if the property has been loaded or not.
Based on my really simple tests, the API works fine. If you want you can use it for your tests.


public static boolean isPropertyLoaded(Object entity, String property) {
		PersistenceCapable pc = (PersistenceCapable) entity;
		StateManagerImpl sm = (StateManagerImpl) pc.pcGetStateManager();
		ClassMetaData metaData = sm.getMetaData();
		FieldMetaData[] fields = metaData.getFields();
		int dx = 0;
		for (int j = 0; j < fields.length; j++) {
			if (fields[j].getName().equals(property)) {
				dx = j;
				break;
			}
		}
		return sm.getLoaded().get(dx);
	}

For forcing initialization you can just call the getter method. I am sure there are better
ways of getting the same information, but this is based on my very limited knowledge of OpenJPA.

Thanks and Regards,
Nitish Kumar

-----Original Message-----
From: jlawmi [mailto:JamesJLaw@gmail.com]
Sent: Sat 3/21/2009 3:12 AM
To: users@openjpa.apache.org
Subject: hibernate conversion items
 

In unit tests (technically integration tests) where I test my mappings,  I
used to call (in hibernate)
Hibernate.isInitialized(someentity.property) to validate things were lazy or
to generally check their load status. Also, Hibernate had
Hibernate.initialize(sometntity.property) to programmatically force
initialization. Is there an easy way to do this in openjpa.? I see the
fetchgroups (which are nice), but configuring a fetchgroup seems overkill in
some cases...

Can someone point me to equivalent items in openjpa?

Thanks!
James
-- 
View this message in context: http://n2.nabble.com/hibernate-conversion-items-tp2511309p2511309.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.



-------------------------------------------------------------------------------------------------------------------------
"The information contained in this e-mail transmission is confidential and may be privileged.
It is intended only for the 
addressee(s) stated above. If you are not an addressee, any use, dissemination, distribution,
publication, or copying of 
the information contained in this e-mail is strictly prohibited. If you have received this
e-mail in error, please 
immediately notify us by telephone (+91 80 6618 6555), or e-mail the sender and delete the
e-mail from your system. 
If you do not want to receive our emails please let us know so that we may delete you from
our email list. Proteans 
Software Solutions and its parent group ("CAMO Group") do not accept liability for damage
caused by this email, and may 
monitor email traffic." 
-------------------------------------------------------------------------------------------------------------------------

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message