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>
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Get-the-persistencUnit-using-EntittyManager-Taking-4-seconds-tp5035800p5035800.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.