Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate JPAContainerFactory不创建数据库表_Hibernate_Postgresql_Vaadin_Vaadin7_Jpacontainer - Fatal编程技术网

Hibernate JPAContainerFactory不创建数据库表

Hibernate JPAContainerFactory不创建数据库表,hibernate,postgresql,vaadin,vaadin7,jpacontainer,Hibernate,Postgresql,Vaadin,Vaadin7,Jpacontainer,我希望JPA容器在“hbm2ddl.auto”设置为“update”时自动创建一个数据库表,但情况似乎并非如此。我的配置是否有问题,或者我是否应该使用其他配置来获得所需的功能 我正在使用以下命令创建一个JPA容器 accounts = JPAContainerFactory.make(Account.class, RumUI.PERSISTENCE_UNIT); Accounts类是 @Entity @Table(name="accounts") public class Accoun

我希望JPA容器在“hbm2ddl.auto”设置为“update”时自动创建一个数据库表,但情况似乎并非如此。我的配置是否有问题,或者我是否应该使用其他配置来获得所需的功能

我正在使用以下命令创建一个JPA容器

accounts = JPAContainerFactory.make(Account.class, RumUI.PERSISTENCE_UNIT);
Accounts类是

@Entity
@Table(name="accounts")    
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(generator="increment")
    @GenericGenerator(name="increment", strategy = "increment")
    private Long id;

    @NotNull
    @Size(min = 2, max = 24)
    @Column(name = "name", unique=true)
    private String name;

    @NotNull
    @Email
    @Column(name = "email")
    private String email;

    @NotNull
    @Size(min = 2, max = 24)
    @Column(name = "password")
    private String password;

    @NotNull
    @Column(name = "role")
    private String role;

    public Account() {
    }

    //getters and setters

}
还有persistence.xml

<persistence-unit name="RuM">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>ee.ut.cs.rum.domain.Account</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
            <property name="hibernate.connection.url" value="jdbc:postgresql://127.0.0.1:5432/RuM"/>
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
            <property name="hibernate.connection.username" value="postgres"/>
            <property name="hibernate.connection.password" value="postgres"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hbm2ddl.auto" value="update"/>
            <property name="hibernate.current_session_context_class" value="thread" />
        </properties>
    </persistence-unit>

org.hibernate.jpa.HibernatePersistenceProvider
ee.ut.cs.rum.domain.Account
我希望数据库表“accounts”会自动创建,因为“hbm2ddl.auto”设置为“update”。但是,不会创建该表

如果我直接使用相同的设置(使用配置对象)创建Hibernate ServiceRegistry和SessionFactory,则会创建该表

我在这里遗漏了什么?

@Entity @表(name=“t\U账户)
公共类帐户……

org.hibernate.ejb.HibernatePersistence
您可以尝试此提供程序

我的问题中缺少实体批注,但它存在于实际源中。否则,ServiceRegistry和SessionFactory也将无法工作。但感谢您的注意。我已相应地编辑了问题。您如何解决问题?我想了解这一点。谢谢!用户可以向上投票或向下投票e建议的解决方案。提出问题的用户可以选择其中一个解决方案作为已接受的解决方案。能否显示您的应用程序context.xml。
accounts=JPAContainerFactory.make(Account.class,RumUI.PERSISTENCE\u UNIT)
l在我的jpa项目中从来没有使用过这个。我想知道,为什么你需要这个。我相信vaadin有applicationcontext.xml文件。至少我的项目中没有。我的项目基于默认的vaadin项目。我尝试了一下,仍然忽略了“hbm2ddl.auto”==“update”设置。我觉得这是vaadin的jpa容器特定的