Я пытаюсь создать такую ситуацию:
Пользователь --------> Рейтинг пользователя об авторе <------------ Автор </p>
Итак, я получил класс:
public class User implements UserDetails {
@Id
private String username;
(...)
@OneToMany(targetEntity=RateAth.class, mappedBy="user", cascade=CascadeType.ALL)
List<RateAth> authorRates
public class Author {
@Id
private int id;
(...)
@OneToMany(targetEntity=RateAth.class, mappedBy="author", cascade=CascadeType.ALL)
private List<RateAth> authorRates;
А вот мой класс RateAth:
@Entity
@Table(name="users_authors_rate")
public class RateAth {
@Id
private PK primaryKey;
private Integer rate;
private Date date;
private String username;
@Id
public PK getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(PK primaryKey) {
this.primaryKey = primaryKey;
}
public Integer getRate() {
return rate;
}
public void setRate(Integer rate) {
this.rate = rate;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public User getUser() {
return primaryKey.getUser();
}
public void setUser(User user) {
this.primaryKey.setUser(user);
}
public Author getAuthor() {
return primaryKey.getAuthor();
}
public void setAuthor(Author author) {
this.primaryKey.setAuthor(author);
}
}
@Embeddable
class PK implements Serializable{
@ManyToOne
@JoinColumn(name="username")
private User user;
@ManyToOne
@JoinColumn(name="author_id")
private Author author;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
}
... еще 49 Причины: org.hibernate.MappingException: не удалось
определить тип для: beans.Author, в таблице: users_authors_rate, для
столбцы: [org.hibernate.mapping.Column (автор)] в
org.hibernate.mapping.SimpleValue.getType (SimpleValue.java:292) в
org.hibernate.mapping.SimpleValue.isValid (SimpleValue.java:276) в
org.hibernate.mapping.Property.isValid (Property.java:207) в
org.hibernate.mapping.PersistentClass.validate (PersistentClass.java:458)
в org.hibernate.mapping.RootClass.validate (RootClass.java:215) в
org.hibernate.cfg.Configuration.validate (Configuration.java:1135) в
org.hibernate.cfg.Configuration.buildSessionFactory (Configuration.java:1320)
в
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory (AnnotationConfiguration.java:867)
в
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory (LocalSessionFactoryBean.java:860)
в
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory (LocalSessionFactoryBean.java:779)
в
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet (AbstractSessionFactoryBean.java:211)
в
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1477)
в
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1417)
... еще 56