Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Is there a method for checking if an object (Entity or attribute) is loaded?

På mandag 08. juli 2013 kl. 15:21:13, skrev Tom Ware <tom.ware@xxxxxxxxxx>:
Hi Andreas,

  The best suggestion I can think of is to write a similar method.  You can leverage the behavior already provided by persistenceUnitUtil.isLoaded(value).  In addition to that, you can do your own check for null.  The additional code you will have to add is EclispeLink specific.  Essentially what you need to do is check whether EclispeLink thinks the class of the object is one that is an Entity. You can do that using our org.eclipse.persistence.jpa.JpaHelper utility.  It provides a set of method that allow you to get at the EclipseLink internals from a JPA class.  One thing you could do is this:

  Session session = JpaHelper.getDatabaseSession(entityManagerFactory);
  if (session.getClassDescriptor(object.getClass()) != null){
      // this indicates this is an Entity/MappedSuperclass//Embeddable
 
Ok, that's usefull, I'll try it. Thanks.
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Back to the top