小编Ale*_*nov的帖子

Vaadin JpaContainer

我正在使用JPAContainer + Hibernate,加载需要很长时间.例如,SQLContainer加载60ms的页面和JPA Container加载1.30s的相同页面.

在控制台中使用JPAContainer,我看到许多SQL查询 - 对于每个实体 - 查询; 实体人员没有其他表格的链接;

使用jpacontainer的代码:

JPAContainer<Person> container = JPAContainerFactory.make(Person.class,
            "persistence-unit");
table.setContainerDataSource(container);
Run Code Online (Sandbox Code Playgroud)

使用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);
Run Code Online (Sandbox Code Playgroud)

我的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 …
Run Code Online (Sandbox Code Playgroud)

hibernate vaadin

12
推荐指数
1
解决办法
5052
查看次数

标签 统计

hibernate ×1

vaadin ×1