我使用JavaEE7,休眠,jpa2.1
我的項目有太多的實體(約2000單位)
如果只有100對象實體,它啓動正常。
但現在我已經添加了我所有的業務實體類(2000年),我得到一個pergem空間誤差。
當JPA休眠掃描太多的實體,GlassFish的啓動速度很慢或memorry泄漏
2016-12-29T11:40:36.903+0700|Severe: Exception in thread "DynamicReloader"
2016-12-29T11:40:36.904+0700|Severe: java.lang.OutOfMemoryError: GC overhead limit exceeded
2016-12-29T11:40:37.899+0700|Severe: Exception in thread "AutoDeployer"
2016-12-29T11:40:37.900+0700|Severe: java.lang.OutOfMemoryError: GC overhead limit exceeded
我已經提高JVM的內存參數,但現在我的應用程序是在啓動時非常慢。
所以,我想知道,如果有一些選項,更快地加載此實體? 預先感謝
這是例如實體
@Entity
@Table(name = "TBL_USER")
@NamedQueries({
@NamedQuery(name = "TblUserO.findAll", query = "SELECT t FROM TblUserO t")
})
public class TblUserO implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "USER_ID", unique = true, nullable = false, precision = 11)
private Long userId;
的persistence.xml
<persistence-unit name="c1spostgre1" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/__PSG1</jta-data-source>
<!-- Named JPQL queries per entity, but any other organization is possible -->
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
<!-- <property name="hibernate.archive.autodetection" value="class" /> -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL92Dialect" />
<property name="hibernate.jdbc.batch_size" value="20" />
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.order_inserts" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="c1spostgre2" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/__PSG2</jta-data-source>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
<!-- <property name="hibernate.archive.autodetection" value="class" /> -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL92Dialect" />
<property name="hibernate.jdbc.batch_size" value="20" />
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.order_inserts" value="true"/>
</properties>
</persistence-unit>