ошибка гибернации - PullRequest
       1

ошибка гибернации

1 голос
/ 09 января 2012

Hy снова,

Вчера все работало нормально, и сегодня я получаю следующую ошибку, когда начинаю с одинаковым кодом в классе и файле гибернации. Кто-нибудь знает, что случилось?

15:56:26 ERROR [AWT-EventQueue-0] (XMLHelper.java:81) - Error parsing XML: XML InputStream(4) The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
null
15:56:26 ERROR [AWT-EventQueue-0] (XMLHelper.java:81) - Error parsing XML: XML InputStream(4) The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
15:56:26 ERROR [AWT-EventQueue-0] (XMLHelper.java:81) - Error parsing XML: XML InputStream(13) The element type "hibernate-mapping" must be terminated by the matching end-tag "</hibernate-mapping>".
Cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [app-data.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
15:56:26 ERROR [AWT-EventQueue-0] (XMLHelper.java:81) - Error parsing XML: XML InputStream(13) The element type "hibernate-mapping" must be terminated by the matching end-tag "</hibernate-mapping>".

Я написал файл отображения hibernate для класса Utilizator, который использует таблицу Utilizatori в SQL 2008, и я получаю следующую ошибку, когда класс вызывается приложением:

Cause: org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'utilizatorDAO' defined in class path resource [app-data.xml]: 
    Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanInitializationException: 
    Initialization of DAO failed; nested exception is org.springframework.orm.hibernate3.HibernateQueryException: 
    Utilizatori is not mapped [from Utilizatori where utilizator = ?]; 
nested exception is org.hibernate.hql.ast.QuerySyntaxException: 
    Utilizatori is not mapped [from Utilizatori where utilizator = ?]

Вот код класса:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package domain;

/**
 *
 * @author Admin
 */
public class Utilizator {

    private Long idUtilizator;
    private String utilizator;
    private String parola;
    private String nivelAcces;
    private String nume;
    private String prenume;

    public Utilizator() {

    }

    public Long getIdUtilizator() {
        return idUtilizator;
    }

    public void setIdUtilizator(Long idUtilizator) {
        this.idUtilizator = idUtilizator;
    }

    public String getUtilizator() {
        return utilizator;
    }

    public void setUtilizator(String utilizator) {
        this.utilizator = utilizator;
    }

    public String getParola() {
        return parola;
    }

    public void setParola(String parola) {
        this.parola = parola;
    }

    public String getNivelAcces() {
        return nivelAcces;
    }

    public void setNivelAcces(String nivelAcces) {
        this.nivelAcces = nivelAcces;
    }

    public String getNume() {
        return nume;
    }

    public void setNume(String nume) {
        this.nume = nume;
    }

    public String getPrenume() {
        return prenume;
    }

    public void setPrenume(String prenume) {
        this.prenume = prenume;
    }

}

и файл сопоставления:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="domain.Utilizator" table="Utilizatori"/>

        <id name="idUtilizator" column="IDUtilizator">
            <generator class="native" />
        </id>       

        <property name="utilizator"/>
        <property name="parola"/>
        <property name="nivelAcces"/>
    </class>             
</hibernate-mapping>

1 Ответ

2 голосов
/ 09 января 2012

Ваш запрос неверен; он должен использовать имя класса, а не имя таблицы базы данных; то есть используйте Utilizator, а не Utilizatori.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...