真的是没办法了!jpa大神请进

tiaozhanmaidi 2013-04-09 09:05:19
弄了一晚上,就是无法自动创建表,单元测试通过了,没报错,就是不能创建表,用的是sqlServer2008,数据库连接是没问题的,在线等大神

code如下:

persistence.xml

<?xml version="1.0"?>
<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">
<!-- file:///D:\hibernate\hibernate-entitymanager-3.3.2.CR1\resources\org\hibernate\ejb\persistence_1_0.xsd -->
<persistence-unit name="demo" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value="123"/>
<property name="hibernate.connection.url" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=demo"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.jdbc.fetch_size" value="18"/>
<property name="hibernate.jdbc.batch_size" value="10"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
</properties>

java代码

package com.hongle.bean.product;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class ProductType {
private int typeId;

@Id @GeneratedValue(strategy=GenerationType.AUTO)
public int getTypeId() {
return typeId;
}

public void setTypeId(int typeId) {
this.typeId = typeId;
}


}


java代码

package junit.test;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.junit.BeforeClass;
import org.junit.Test;

import junit.framework.TestCase;

public class ProductTest{

@BeforeClass
public static void setUpBeforeClass() throws Exception {
}

@Test
public void testRun(){
Persistence.createEntityManagerFactory("demo");

}

}

可恨的是没有报错,改都不知道怎么改
...全文
36 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧