Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] does a similar function like "void Session.load(Object object, Serializable id) " in Hibernate

Hi Ajax,

  How does the load function compare to the JPA function, getReference()?

/**
* Get an instance, whose state may be lazily fetched.
* If the requested instance does not exist in the database,
* the EntityNotFoundException is thrown when the instance
* state is first accessed. (The persistence provider runtime is
* permitted to throw the EntityNotFoundException when
* getReference is called.)
* The application should not expect that the instance state will
* be available upon detachment, unless it was accessed by the
* application while the entity manager was open.
* @param entityClass
* @param primaryKey
* @return the found entity instance
* @throws IllegalArgumentException if the first argument does
* not denote an entity type or the second argument is
* not a valid type for that entity’s primary key or
* is null
* @throws EntityNotFoundException if the entity state
* cannot be accessed
*/
public <T> T getReference(Class<T> entityClass,
Object primaryKey);

  That function is supported by EclipseLink.

-Tom

On 10/07/2013 6:39 AM, Ajax Zhang wrote:
Hi all,

We migrate the project from hibernate to eclipselink.
But we use the hibernate load api a lot. It can directly change the toLoaded Entity ,not need to set the return value to the reference.

    void org.hibernate.Session.load(Object object, Serializable id) throws HibernateException
        Read the persistent state associated with the given identifier into the given transient instance.
        Parameters:
        object an "empty" instance of the persistent class
        id a valid identifier of an existing persistent instance of the class
        Throws:
        HibernateException


Does the eclipselink have the similar soluction,
  1.  should I need to change all the place
  2. use beanutil or java reflect to copy the properties 
  3. or any other soluction?





--
Thanks & Best Regards,
Ajax


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top