当前位置: 代码迷 >> JBoss >> org.hibernate.hql.ast.QuerySyntaxException,该如何解决
  详细解决方案

org.hibernate.hql.ast.QuerySyntaxException,该如何解决

热度:4818   发布时间:2013-02-26 00:00:00.0
org.hibernate.hql.ast.QuerySyntaxException
="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="student"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- 
<jta-data-source>java:/student</jta-data-source>
-->
<properties>
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/student?characterEncoding=UTF-8" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password"
value="666666*" />
<!-- 
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.hbm2ddl.auto" value="update" />
-->
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>

=============================================================================================

package com.fengmanfei.student.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity(name = "tb_class")
//@Table(name = "tb_class")
public class ClassEO implements Serializable {

private static final long serialVersionUID = 4231121505530870021L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

@Column
private String name;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "classEO")
private Set<StudentEO> students = new HashSet<StudentEO>();

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Set getStudents() {
return students;
}

public void setStudents(Set<StudentEO> students) {
this.students = students;
}

}

=============================================================================
package com.fengmanfei.student.servlet;

import java.io.IOException;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
  相关解决方案