persistence@glassfish.java.net

Re: no.weaving option

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Thu, 12 Jan 2006 23:27:39 +0530

Pierre Delisle wrote:

>Mitesh,
>
>
>
>>Please pass a HashMap to createEntityManagerFactory as follows to work
>>around the NPE.
>> EntityManagerFactory emf =
>>Persistence.createEntityManagerFactory("em", new HashMap());
>>
>>
>
>This did the trick. Many thanks for the quick reply!
>Please let me know if I should file a bug.
>
>
>
There are two issues here:
1) The sample code in our website should be fixed b'cos it uses a
non-standard method. Spec does not mention about
createEntityManagerfactory(String).

2) Secondly, the javadocs (see below) do not say that properties
argument can't be null. So TopLink should not throw NPE.
Pl. file a bug for this.

Thanks,
Sahoo

PFD version of javax.persistence.Persistence.class:

/**
* Bootstrap class that is used to obtain an
* EntityManagerFactory, from which EntityManager
* references can be obtained.
*/
public class Persistence {
/**
* Create and return an EntityManagerFactory for the
* named persistence unit.
*
* @param persistenceUnitName The name of the persistence unit
* @return The factory that creates EntityManagers configured
* according to the specified persistence unit
*/
public static EntityManagerFactory createEntityManagerFactory(
String persistenceUnitName) {...}
/**
* Create and return an EntityManagerFactory for the
* named persistence unit using the given properties.
*
* @param persistenceUnitName The name of the persistence unit
* @param props Additional properties to use when creating the
* factory. The values of these properties override any values
* that may have been configured elsewhere.
* @return The factory that creates EntityManagers configured
* according to the specified persistence unit.
*/
public static EntityManagerFactory createEntityManagerFactory(
String persistenceUnitName, Map properties) {...}
...
}

> -- Pierre
>
>