Jboss6.0部署EJB项目以后无法在数据库中自动创建表
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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" version="1.0">
<persistence-unit name="testJPA" transaction-type="JTA">
<jta-data-source>java:/MySqlDS</jta-data-source>
<class>com.pojo.Person</class>
<!-- 声明是否扫描jar文件中标注了@Enity类.若不扫描,值为true 默认也是true -->
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hbm2ddl.auto" value="update" />
<property name="show_sql" value="true" />
<property name="format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
实体类:
package com.pojo;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Person {
private String name;
private int age;
private int id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
我自己在数据库中建立person以后可以远程调用执行数据插入操作,我现在很郁闷的是在启动jboss的时候不能够自动建表???求大神指点!!感激不尽。
[解决办法]
看起来是没错,
你的数据源加载没问题吗?数据源所配的用户,是否有权限建表呢