在WildFly Server上启动Web应用程序时,出现此无意义的错误:Repeated column in mapping for entity: persistence.dto.User column: name (should be mapped with insert="false" update="false")
但是表“ users”中只有一个“ name”列。整个应用程序不使用联接或关系。
我的应用程序中还有一个名为“ name”的字段,但是这两个表是彼此完全独立的。
@Entity
@Table(name="users")
@SequenceGenerator(name="id", initialValue=1, allocationSize=1)
public class User implements BaseDTO {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id", nullable=false, length = 4)
private int id;
@Column(name="name", nullable=false, length = 100)
private String name;
@Column(name="username", nullable=false, length = 50, unique = true)
private String username;
@Column(name="name", nullable=false, length = 60)
private String pwhash;
@Column(name="name", nullable=true, length = 50)
private String avatar;
@Column(name="email", nullable=false, length = 80, unique = true)
private String email;
@Column(name="totpSecretKey", nullable=false, length = 16, unique = true)
private String totpSecretKey;
@Column(name="active", nullable=false, length = 1)
private boolean active;
@Column(name="activation", nullable=true, length = 13)
private String activation;
@Column(name="registerDate", nullable=true, length = 10)
@Temporal(TemporalType.TIMESTAMP)
private Date registerDate;
@Column(name="lastVisitDate", nullable=true, length = 10)
@Temporal(TemporalType.TIMESTAMP)
private Date lastVisitDate;
@Column(name="street", nullable=false, length = 100)
private String street;
@Column(name="house", nullable=false, length = 10)
private String house;
@Column(name="city", nullable=false, length = 50)
private String city;
@Column(name="plz", nullable=false, length = 5)
private int plz;
@Column(name="birthday", nullable=true, length = 10)
@Temporal(TemporalType.DATE)
private Date birthday;
@Column(name="phone", nullable=false, length = 25, unique = true)
private String phone;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
// other getters and setters, equals, hashCode, toString
}
这是我的映射:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration()
.addPackage("persistence.dto")
.addAnnotatedClass(AppSettings.class)
.addAnnotatedClass(Ereignis.class)
.addAnnotatedClass(Fragebogen.class)
.addAnnotatedClass(Schwimmvideo.class)
.addAnnotatedClass(User.class)
.addAnnotatedClass(UserHasGroup.class)
.addAnnotatedClass(Usergroup.class)
.configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}