我正在开发这个JPAContainer + Hibernate,并且需要很长时间才能加载。例如,SQLContainer加载60ms的页面和JPA Container加载1.30s的页面。Vaadin JpaContainer
在控制台中使用JPAContainer我看到很多SQL查询 - 对于每个实体 - 查询;实体人员没有指向其他表的链接;
代码jpacontainer:
JPAContainer<Person> container = JPAContainerFactory.make(Person.class,
"persistence-unit");
table.setContainerDataSource(container);
代码SQLContainer:
JDBCConnectionPool pool = null;
try {
pool = new SimpleJDBCConnectionPool("org.postgresql.Driver",
"jdbc:postgresql://127.0.0.1:5432/postgres", "postgres",
"pwd");
} catch (SQLException e) {
e.printStackTrace();
}
TableQuery tq = new TableQuery("Person", pool);
SQLContainer sqlContainer = null;
try {
sqlContainer = new SQLContainer(tq);
} catch (SQLException e) {
e.printStackTrace();
}
table.setContainerDataSource(sqlContainer);
我的persistence.xml文件:
<persistence-unit name="persistence-unit" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:jboss/datasources/mfc-frontendDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
</properties>
我在做什么错?
请注意,Vaadin的JPA容器目前有*免费许可证*。 –