Do you really need the following in your persistence.xml?
<exclude-unlisted-classes>false</exclude-unlisted-classes>
Listing all of your entity classes and then setting it to true along
with adding
<properties>
<property name="openjpa.DynamicEnhancementAgent"
value="true"/>
</properties>
which turns off dynamic enhancement (which means you have to use build
time enhancement) may help your speed issue (without more profiling data
to go on....)
-Donald
On 5/11/10 8:52 AM, SreeAsh wrote:
>
> Hi
>
> I am using the following code to get the persistenceUnit, but taking 4
> seconds to connect can i reduce the same.please find the below code
>
> public static EntityManager getSQLEM() {
> try {
> if (em == null) {
> emf =
> Persistence.createEntityManagerFactory(ConstantUtil.SQLSERVER_PERSISIT_UNIT);
> em = emf.createEntityManager();
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> return em;
> }
>
> and i have the persistence xml like this
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>
> <!--SQl Server Persistence Unit-->
> <persistence-unit name="CRMSQL" transaction-type="RESOURCE_LOCAL">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>
> <class>com.epoint.entity.common.UserInformation</class>
> <class>com.epoint.entity.common.ProductUserRole</class>
> <class>com.epoint.entity.common.ProductRoleObject</class>
> <class>com.epoint.entity.common.ProductObject</class>
> <class>com.epoint.entity.common.AccessLookup</class>
> <class>com.epoint.entity.common.CompoundKeyAccessLookup</class>
>
> <!--Srini Added-->
> <class>com.epoint.entity.campaign.Campaign</class>
>
> <exclude-unlisted-classes>false</exclude-unlisted-classes>
> <properties>
> <property name="openjpa.ConnectionUserName" value="sa"/>
> <property name="openjpa.ConnectionPassword" value="password"/>
> <property name="openjpa.ConnectionURL"
> value="jdbc:sqlserver://host:port;databaseName=test"/>
> <property name="openjpa.ConnectionDriverName"
> value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
> <property name="openjpa.jdbc.Schema" value="dbo"/>
> <!--<property name="openjpa.Log" value="DefaultLevel=ERROR,
> SQL=TRACE"/>-->
> </properties>
> </persistence-unit>
> <!--SQl Server Persistence Unit End-->
>
> </persistence>
>