gpt4 book ai didi

java - 解析 Hibernate Man.hbm.xml 时出错

转载 作者:行者123 更新时间:2023-11-30 09:26:43 24 4
gpt4 key购买 nike

我无法运行我的 hibernate 应用程序。我经常收到此错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/MAG/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/MAG/.m2/repository/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
2013-02-14 14:49:05 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.3.0.SP1
2013-02-14 14:49:05 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
2013-02-14 14:49:05 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
2013-02-14 14:49:05 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
2013-02-14 14:49:05 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
2013-02-14 14:49:05 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
2013-02-14 14:49:05 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : model/man/Man.hbm.xml
2013-02-14 14:49:06 org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(25) Attribute "name" must be declared for element type "many-to-many".
2013-02-14 14:49:06 org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(33) Attribute "name" must be declared for element type "many-to-many".
2013-02-14 14:49:06 org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(38) The content of element type "set" must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".

我的程序的想法是:ManOwnerRenter 的父类(super class)。
业主可以拥有多个单位,但单位只能有一个业主。
Renter 可以有多个 RenterBill,但 RenterBill 可以有一个 Renter。
承租人可以有很多公寓,公寓也可以有很多承租人。

我的 Man.hbm.xml:

<class name="Man" table="MEN">
<id name="id" column="MAN_ID">
<generator class="native" />
</id>
<property name="pesel" column="MAN_PESEL" />
<property name="idNumber" column="MAN_ID_NUMBER" />
<property name="email" column="MAN_EMAIL" />
<property name="name" column="MAN_NAME" />
<property name="surname" column="MAN_SURNAME" />
<property name="telephoneNumber" column="MAN_TELEPHONE_NUMBER" />
<many-to-one name="address" column="ADDRESS_ID" not-null="true" />

<joined-subclass name="Owner" table="OWNERS">
<key column="MAN_ID" />
<property name="password" column="OWNER_PASSWORD" not-null="true" />
<property name="seed" column="OWNER_SEED" not-null="true" />
<set name="flats" table="OWNER_FLATS">
<key column="MAN_ID" />
<many-to-many name="flats" column="FLAT_ID" class="Flat" />
</set>
</joined-subclass>

<joined-subclass name="Renter" table="RENTERS">
<key column="MAN_ID" />
<set name="flats" table="RENTER_FLATS">
<key column="MAN_ID" />
<many-to-many name="flats" column="FLAT_ID" class="Flat" />
</set>
<set name="bills" table="RENTER_BILLS">
<key column="MAN_ID" />
<many-to-one name="bills" column="RENTER_BILL_ID" class="RenterBill" />
</set>
</joined-subclass>
</class>

Java 类:人.java

package model.man;
import model.addresses.Address;
public abstract class Man {

private int id;
private String pesel;
private String idNumber;
private String email;
private String name;
private String surname;
private String telephoneNumber;
private Address address;

/* getters setters */
}

所有者.java

package model.man;

import java.util.Iterator;
import java.util.Set;

import model.flat.Flat;

public class Owner extends Man implements Iterable<Flat> {

private String password;
private String seed;
private Set<Flat> flats;

/* getters setters */
}

租客.java

package model.man;

import java.util.HashSet;
import java.util.Set;

import model.bills.RenterBill;
import model.flat.Flat;

public class Renter extends Man {

private Set<Flat> flats = new HashSet<Flat>();
private Set<RenterBill> bills = new HashSet<RenterBill>();

/* getters setters */
}

最佳答案

SEVERE: Error parsing XML: XML InputStream(25) Attribute "name" must be declared for element type "many-to-many".
2013-02-14 14:49:06 org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(33) Attribute "name" must be declared for element type "many-to-many".
2013-02-14 14:49:06 org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(38) The content of element type "set" must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".

尝试从多对多标签中删除“名称”属性。

更新

您也有一个映射为多对一的集合。这通常在您的 Java POJO 中显示为引用类的单个实例。您可能打算在那里使用一对多标记。

关于java - 解析 Hibernate Man.hbm.xml 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14876506/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com