我是JPA的新手,也是从EclipseLink开始的.从教程中获取帮助,我开始创建我的第一个JPA项目,该项目包含一个实体(使用JPA工具自动创建),这是一个触发最基本选择查询的简单主类.但是,当我尝试运行主类时,我得到一个PersistenceUnit预部署失败的异常.我使用SQL Server express 2008并查询示例AdventureWorks数据库.能够连接到数据库(使用Database Development Perspective).详细的错误日志和代码片段如下:
主要课程
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import model.Employee;
public class Main {
public static void main(String[] args) {
EntityManager em = Persistence.createEntityManagerFactory("JPA2").createEntityManager();
List<Employee> list = em.createQuery("Select * from humanresources.Employee", Employee.class).getResultList();
for(Employee e : list)
{
System.out.println(e.getBirthDate());
}
}
}
Run Code Online (Sandbox Code Playgroud)
实体
package model;
import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="BusinessEntityID")
private int businessEntityID;
@Column(name="BirthDate")
private Object birthDate;
@Column(name="Gender")
private …Run Code Online (Sandbox Code Playgroud) 谁能告诉我JavaScript在这里做的事情.
var myArray = ["Hello", "world"]
console.log(myArray[length])Run Code Online (Sandbox Code Playgroud)
我们得到输出为Hello.